Results 1 to 4 of 4

Thread: QKeyEvent and getting all 'F' key presses

  1. #1
    Join Date
    Jun 2011
    Posts
    23
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QKeyEvent and getting all 'F' key presses

    Hi,

    Just wondering if there is a way to single out all the 'F' keys (F1 through to F12) in one go when I have a keyPressEvent(QKeyEvent *k) without having to list then all like this

    if(k->key() == Qt::Key_F1)
    if(k->key() == Qt::Key_F2)

    etc...

    Thank you very much

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent and getting all 'F' key presses

    Qt Code:
    1. if(k->key() >= Qt::Key_F1 && k->key() <= Qt::Key_F12)
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2011
    Posts
    23
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QKeyEvent and getting all 'F' key presses

    Thank you very much. I was unsure if the < > could be used in this case.

    cheers!!

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent and getting all 'F' key presses

    In this case you can. If the set of tested values is discontinuous, you can define static QVector<int> with all values and use the QVector::indexOf method

Similar Threads

  1. How to monitor global key presses
    By vanillac in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2015, 10:23
  2. Something about the QKeyEvent in Qt3
    By cspp in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2009, 03:38
  3. signals for key presses ?
    By eGamer in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2009, 10:12
  4. QKeyEvent
    By peace_comp in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2008, 14:13
  5. QKeyEvent
    By sonuani in forum Newbie
    Replies: 8
    Last Post: 25th February 2008, 08:38

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.