Results 1 to 5 of 5

Thread: QShortcut

  1. #1
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QShortcut

    Only the first defined shortcut works. Why?

    Qt Code:
    1. QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
    2. connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));
    3.  
    4. QShortcut* shortcut2 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_LEFT, ButtonKeyDefines::QKEY_RIGHT), pTableWidget);
    5. connect(shortcut2, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QShortcut

    What are the values for -
    ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT
    ButtonKeyDefines::QKEY_LEFT, ButtonKeyDefines::QKEY_RIGHT


    Also what happens if you change the order to -
    Qt Code:
    1. QShortcut* shortcut2 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_LEFT, ButtonKeyDefines::QKEY_RIGHT), pTableWidget);
    2. connect(shortcut2, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));
    3.  
    4. QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
    5. connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));
    To copy to clipboard, switch view to plain text mode 


    ??

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut

    try to use another key sequence, i.e. ctrl+key left.

  4. #4
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QShortcut

    If i change the order shortcut2 will work not shortcut1...

    I develop for an embedded system and the buttons are limited. The buttons key id:s are read from a keypress device on the system and mapped to qt keypresses...

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QShortcut

    As I asked,, what are the values for ..
    ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT
    ButtonKeyDefines::QKEY_LEFT, ButtonKeyDefines::QKEY_RIGHT
    ????????????
    if the values for ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT and ButtonKeyDefines::QKEY_LEFT are same, then that is causing the prob. In case they are different, probably something else is wrong. hard to say much without seeing more code

    Also if the both left values are same, u dont need to define 2 shortcuts,,, one will do -

    Qt Code:
    1. QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
    2. connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));
    3. connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));
    To copy to clipboard, switch view to plain text mode 

    try it, hope it helps.

Similar Threads

  1. QShortcut - doesn't work with Qt::Key_Return
    By naresh in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2006, 12:00

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.