Results 1 to 12 of 12

Thread: QEvent::KeyPress problem, when will this event appear?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Post QEvent::KeyPress problem, when will this event appear?

    I have a widget and installed event filter to it,

    Qt Code:
    1. bool MyClass::eventFilter( QObject*, QEvent *event )
    2. {
    3. qDebug("EventFilter type: %d", event->type());
    4. QKeyEvent *ke = (QKeyEvent *) event;
    5. int keyValue = ke->key();
    6. if(event->type() == QEvent::KeyPress )
    7. {
    8. switch ( keyValue )
    9. {
    10. case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3 : case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9 :
    11. ListBoxA->numClicked((char *)ke->text().latin1());
    12. break;
    13. }
    14. return true;
    15. }
    16. return false;
    17. }
    To copy to clipboard, switch view to plain text mode 


    From the qDebug(), I found that the QEvent::KeyPress appear only once, that is, the first time I press a keyboard input. And all keyboard input afterward seems disappeared, no more can be received. However if I change it to QEvent::KeyRelease, I found that it works!

    Can anyone tell me why is this happening? When will the KeyPress event occur? is it the eventFilter is not working or something else blocked the event?

    QT4.6.3 used.

    Thanks!
    Last edited by batileon; 16th June 2011 at 08:01.

Similar Threads

  1. problem with keypress event and QTableView
    By ranna in forum Qt Programming
    Replies: 4
    Last Post: 24th August 2009, 16:13
  2. how to combine keypress event and mousebuttonpress event?
    By hildebrand in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2009, 23:08
  3. [Qt4.5] event(QEvent * event) freeze application
    By czlowiekcien in forum Newbie
    Replies: 2
    Last Post: 25th May 2009, 20:25
  4. Problem with KeyPress event and QTableView
    By ranna in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 20:01
  5. keypress event
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2007, 14:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.