Results 1 to 3 of 3

Thread: Keyboard combinations in QTableWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Keyboard combinations in QTableWidget

    Try this:

    Qt Code:
    1. void MainWindow::keyPressEvent(QKeyEvent *event)
    2. {
    3. switch (event->key())
    4. {
    5. case Qt::Key_Delete:
    6. qDebug() << "[Del]";
    7. break;
    8. case Qt::Key_Up:
    9. if (event->modifiers() & Qt::AltModifier)
    10. qDebug() << "[Alt + Up]";
    11. break;
    12. case Qt::Key_Down:
    13. if (event->modifiers() & Qt::AltModifier)
    14. qDebug() << "[Alt + Down]";
    15. break;
    16. default: QMainWindow::keyPressEvent(event); // << important!
    17. }
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    Works here; should work for you also...

  2. #2
    Join Date
    Dec 2010
    Posts
    55
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Keyboard combinations in QTableWidget

    This doesn't work for me, infact it never gets called.

    I think this is because QTableWidget "intercepts" the Key_Up and Key_Down events before it gets to me since it uses those keys for navigation.
    Running:
    RHEL 5.4
    Python 2.7.2
    Qt 4.7.4
    SIP 4.7.8
    PyQt 4.7

Similar Threads

  1. Replies: 4
    Last Post: 16th September 2011, 02:10
  2. Replies: 26
    Last Post: 12th April 2011, 14:06
  3. Replies: 1
    Last Post: 6th January 2011, 04:19
  4. Capture key & key combinations from keyboard
    By aikidorb in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2010, 13:13
  5. Replies: 2
    Last Post: 22nd July 2007, 19:21

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.