Results 1 to 1 of 1

Thread: Keypress never fired on lineedit qcombobox

  1. #1
    Join Date
    Nov 2007
    Posts
    24
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Keypress never fired on lineedit qcombobox

    Hi,

    I added an eventfilter() to the lineedit() of a qcombobox
    Then event() is called but not the keypress type.


    Qt Code:
    1. // create combo
    2. //
    3. cb = new QComboBox();
    4. ...
    5. cb->setEditable(true);
    6. cb->lineEdit()->installEventFilter(this);
    7.  
    8. ...
    9.  
    10. bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    11. {
    12. if (obj==cb->lineEdit())
    13. {
    14. // lots of events are fired but never keypress !!??
    15. if (event->type() == QEvent::KeyPress)
    16. {
    17. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    18.  
    19. if (keyEvent->key() == Qt::Key_Period)
    20. {
    21. ....
    22. return true;
    23. }
    24. }
    25.  
    26. return false;
    27. }
    28. else
    29. return QMainWindow::eventFilter(obj, event);
    30. }
    To copy to clipboard, switch view to plain text mode 

    I've got the feeling I've forgotten something but what ??

    Thanks...


    Added after 28 minutes:


    I guess I understand,

    EventFilter() must be on combo and not on lineedit !!!
    Wow not so easy...

    A big Thanks to the open source !!!
    Last edited by stef13013; 6th August 2012 at 17:46.

Similar Threads

  1. Replies: 2
    Last Post: 28th February 2011, 00:45
  2. mouseMoveEvent during drag is not fired
    By gruszczy in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 22:04
  3. QMenu still highligheted after action fired in mac
    By berinder in forum Qt Programming
    Replies: 2
    Last Post: 1st September 2008, 20:53
  4. Replies: 2
    Last Post: 17th July 2006, 15:52
  5. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 20:43

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.