Hi,
im having a problem with 3 key shortcut. I'm trying to add to an action this:
but isn't trigeer, does anyone have an idea how to implement a 3 Key Shortcut??Qt Code:
To copy to clipboard, switch view to plain text mode
THANKS
Hi,
im having a problem with 3 key shortcut. I'm trying to add to an action this:
but isn't trigeer, does anyone have an idea how to implement a 3 Key Shortcut??Qt Code:
To copy to clipboard, switch view to plain text mode
THANKS
Shouldn't it be:
?Qt Code:
To copy to clipboard, switch view to plain text mode
OH YEAH, im sorry, wrong code :P but QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1) also didn't work and QKeySequence(Qt::CTRL,Qt::SHIFT,Qt::Key_1). My concern is if it is able to do it... or somebody have same problems. I have also 2 keys shortcuts in the same class and there are fine.
Try:
Qt Code:
To copy to clipboard, switch view to plain text mode
nothing... I changed it tobut nothing has trigger. Put on it a breakpoint to verify that isn't triggering.Qt Code:
To copy to clipboard, switch view to plain text mode
So obviously the reason is not here. Can we see a larger snippet of code? How do you create and use the action?
Qt Code:
{ createAction( &_actionSortAlpha, pMenu, tr("Alphabetically"), true, QtEnumSortOption::SortAlpha, "", QKeySequence(tr("Ctrl+Shift+1")) ); createAction( &_actionSortPresence, pMenu, tr("Presence"), true, QtEnumSortOption::SortPresence, "", QKeySequence(tr("Ctrl+Shift+2")) ); createAction( &_actionSortRandom, pMenu, tr("Random"), true, QtEnumSortOption::SortRandom, "", QKeySequence(tr("Ctrl+Shift+3")) ); } void QtContactMenu2::createAction( QAction** ppAction, QMenu* pMenu, const QString& text, bool bCheckable, int data, const char* iconPath, QKeySequence & shortcut ){ (*ppAction)->setCheckable( bCheckable ); (*ppAction)->setData(qVariantFromValue(data) ); if ( iconPath && (strlen( iconPath ) > 0 ) ) { QIcon icon1; (*ppAction)->setIcon(icon1); } if (shortcut){ (*ppAction)->setShortcut(shortcut); } pMenu->addAction( *ppAction ); }To copy to clipboard, switch view to plain text mode
First of all please provide a parent for the action.
What is pMenu (I mean the base class of it)? Is it visible anywhere on the screen?
pMenu is a QMenu object, thats the menu on the app.
What difference makes the parent?? I'm asking because if you set this:
Qt Code:
createAction( &_actionSortAlpha, pMenu, tr("Alphabetically"), true, QtEnumSortOption::SortAlpha, "", QKeySequence(tr("Ctrl+1")) );To copy to clipboard, switch view to plain text mode
this shortcut works without any problem...
This works for me just fine:
Qt Code:
#include <QtGui> int main(int argc, char **argv){ QToolButton pb; act->setText("text"); pb.setDefaultAction(act); pb.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
The only reason I can think of is that the menu is not the active widget and thus the action is inactive. But then the second snippet you posted shouldn't have worked as well.
thats the wear part, 2 keys works but 3 dont.
Hey Wisota, is working but only with keyboard numbers, the numbers on the numpad of the keyboard dont react on it, I do it just once but no more.... Are keyboard nums and numpad nums different for QT??
YeapWith or Without the NumLock, Keyboard nums works but NumPad don't
Maybe.... im not pressing CRTL + SHIFT + 1 but I'm pressing CTL + ! (which is SHIFT + 1)> That why sometimes works
I don't know what you are pressing"!" is "!", "Shift+1" is "Shift+1". You can have different keyboard layouts and some of them won't have "!" as "Shift+1". It works for me when I press Ctrl, Shift and 1.
Bookmarks