Results 1 to 2 of 2

Thread: How to get key event in QObject (or how to post a key event to another QObject)

  1. #1
    Join Date
    Oct 2006
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to get key event in QObject (or how to post a key event to another QObject)

    Hi all,
    I dont use any QWidget in my project (use QTimer and QSocket)
    How to handel keyboard.
    i use Qt 2.3.0

    Qt Code:
    1. class clMyObject : public QObject
    2. {
    3. public:
    4. clMyObject(QObject *parent=0, const char *name) : QObject(parent, name) {};
    5. //
    6. bool event(QEvent * e)
    7. {
    8. if (e->type == QEvent::KeyPress)
    9. {
    10. qDebug("Key press");
    11. }
    12. else
    13. {
    14. qDebug("no Key press event %d", e->type());
    15. }
    16. //
    17. return QObject::event();
    18. };
    19. };
    20.  
    21. int main(int argc, char **argv)
    22. {
    23. QAplication a(argc, argv, false);
    24. //
    25. clMyObject MyObject(a);
    26. //
    27. return a.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get key event in QObject (or how to post a key event to another QObject)

    i think not with this. you have to read the stdin.
    with
    Qt Code:
    1. QTextStream textStream(stdin);
    To copy to clipboard, switch view to plain text mode 

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.