PDA

View Full Version : QShortcut



SailinShoes
17th October 2008, 08:00
Only the first defined shortcut works. Why?



QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFT BUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));

QShortcut* shortcut2 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_LEFT , ButtonKeyDefines::QKEY_RIGHT), pTableWidget);
connect(shortcut2, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));

aamer4yu
17th October 2008, 08:23
What are the values for -
ButtonKeyDefines::QKEY_SOFTBUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT
ButtonKeyDefines::QKEY_LEFT, ButtonKeyDefines::QKEY_RIGHT
:confused:

Also what happens if you change the order to -


QShortcut* shortcut2 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_LEFT , ButtonKeyDefines::QKEY_RIGHT), pTableWidget);
connect(shortcut2, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));

QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFT BUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));




??

spirit
17th October 2008, 08:26
try to use another key sequence, i.e. ctrl+key left.

SailinShoes
17th October 2008, 09:23
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...

aamer4yu
17th October 2008, 10:42
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 -


QShortcut* shortcut1 = new QShortcut(QKeySequence(ButtonKeyDefines::QKEY_SOFT BUTTON_LEFT, ButtonKeyDefines::QKEY_SOFTBUTTON_RIGHT), pTableWidget);
connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutMotorTune()));
connect(shortcut1, SIGNAL(activated()), this, SLOT(shortCutSystemInformation()));

try it, hope it helps.