Results 1 to 3 of 3

Thread: cant seem to catch keyboard events for key_return, key_space, key_tab, key_enter

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2017
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default cant seem to catch keyboard events for key_return, key_space, key_tab, key_enter

    I have dialog with space and return references. I want to also be able to catch the physical keystrokes on my keyboard. everything appears to be work except for.
    key_return, key_space, key_tab, key_enter. I am focusing on key_Return not the numpad key_enter.

    the following will not trigger any event for any of the above keys.
    Qt Code:
    1. .h
    2. protected
    3. void keyPressEvent(QKeyEvent *);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. .cpp
    2. void KeyBoard::keyPressEvent(QKeyEvent *event)
    3. {
    4. qDebug()<<"event";
    5. }
    To copy to clipboard, switch view to plain text mode 

    I have also tried the following with no event trigger. all other in keystrokes are working fine.

    Qt Code:
    1. .h
    2. protected
    3. bool eventFilter(QObject *obj, QEvent *event);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. .cpp
    2. bool KeyBoard::eventFilter(QObject* obj, QEvent* event)
    3. {
    4. qDebug()<<"event";
    5. if(event->type() == QEvent::KeyPress) {
    6. QKeyEvent *key = static_cast<QKeyEvent *>(event);
    7. qDebug() << "key " << key->key() << "from" << obj;
    8. }
    9. return QObject::eventFilter(obj, event);
    10. }
    To copy to clipboard, switch view to plain text mode 

    I have been struggling with this for a couple days now.
    Last edited by swankster; 27th June 2018 at 16:11.

Similar Threads

  1. Static compiled Qt application can not catch keyboard event
    By danielsix in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 14th May 2017, 14:18
  2. Catch power events (suspend, resume) on linux
    By Ginsengelf in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2015, 18:55
  3. Catch maximize and restore events.
    By QT8seven in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2014, 01:56
  4. Replies: 3
    Last Post: 28th June 2012, 15:44
  5. Can I use delegate to catch mouse and keyboard events
    By hubbobubbo in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2010, 12:00

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.