You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

EraSER

Beginner

  • "EraSER" is male
  • "EraSER" started this thread

Posts: 7

Location: Russia,Moscow

Occupation: Developer

  • Send private message

1

Thursday, May 27th 2004, 7:06am

Change focus in TextEdit

I want change focus on Key_Tab in QTextEdit
How to do it?
Examine source got such result:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class CTextEdit : public QTextEdit
{
public:
    CTextEdit(QWidget * parent = 0, const char * name = 0 ):
        QTextEdit(parent,name)   {};
    void keyPressEvent( QKeyEvent *e )
    {
        bool res;
        if (e->key() != Key_Tab) QTextEdit::keyPressEvent(e);
        else {
                QFocusEvent::setReason( QFocusEvent::Tab );
                res = focusNextPrevChild( TRUE );
                QFocusEvent::resetReason();
    }
};


It's don't works.
Qt-3.0.0 Only!

e8johan

Professional

  • "e8johan" is male

Posts: 1,195

Location: Sweden

  • Send private message

2

Thursday, May 27th 2004, 7:28am

RE: Change focus in TextEdit

Why don't you use void QTextEdit::setTabChangesFocus ( bool b ). I believe that is it what you are looking for.

EraSER

Beginner

  • "EraSER" is male
  • "EraSER" started this thread

Posts: 7

Location: Russia,Moscow

Occupation: Developer

  • Send private message

3

Thursday, May 27th 2004, 7:50am

Source code

1
2
3
4
5
void keyPressEvent( QKeyEvent *e )
{
        if (e->key() != Key_Tab) QTextEdit::keyPressEvent(e);
        [B]else e->ignore();[/B]
}

It was so simple =)
Now it's work fine!