[Qt-interest] 2 QTextEdit: how to obtain a visible cursor in both at startup
danny
tornadory at 163.com
Fri Jan 14 10:52:04 CET 2011
Hi,
There should be only one focused widget at the same time.
--
Best Regards,
At 2011-01-14 16:56:57,TP <paratribulations at free.fr> wrote:
>Hello,
>
>I have two QTextEdit in my application, with some correspondance between
>both. That is why, I want to show the cursor in both of them at startup.
>To make the cursor always visible in a QTextEdit, I have found that an empty
>reimplementation of focusOutEvent makes the job (see the code below).
>But I have not found a way to make both cursors appear at startup. For the
>time being, the user must click in the second QTextEdit for the cursor to be
>always visible.
>I have tried to play with .setFocus() (see below), but this does not work,
>this is not equivalent to the user clicking in one text edit and then in the
>other, because the cursor remains in one of the text edit at startup, not in
>both.
>
>Any idea?
>
>Thanks a lot
>
>Julien
>
>
>#include <QtGui>
>#include <QtCore>
>
>class QTextEdit2 : public QTextEdit
>{
>
>public:
> void focusOutEvent( QFocusEvent * event );
>};
>
>void QTextEdit2::focusOutEvent( QFocusEvent * event )
>{
>}
>
>int main( int argc, char * argv[] )
>{
> QApplication app( argc, argv );
> QTextEdit2 text1;
> QTextEdit2 text2;
>
> QDialog dialog;
> dialog.resize( 750, 550 );
>
> QVBoxLayout qvboxlayout( &dialog );
> qvboxlayout.addWidget( &text1 );
> qvboxlayout.addWidget( &text2 );
>
> text2.setFocus();
> text1.setFocus();
>
> dialog.show();
> app.exec();
>}
>
>_______________________________________________
>Qt-interest mailing list
>Qt-interest at qt.nokia.com
>http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110114/9cfe4666/attachment.html
More information about the Qt-interest-old
mailing list