How to set hotkey's that work in Linux?
-
I am using QMenu and QAction, I can set and see the visual aid of the hotkey by using underscore, e.g. &Menu works and shows an underscore on the M, but using the Alt+M combination does not trigger the action in Linux.
Using the mouse and clicking on the menu works, this is using Qt 4.8.4
-
@JonB , thank you, I've done this with:
int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator)); if ( intHotKeyIdx >= 0 ) { const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1)); const QKeySequence cobjKeySeq(cstrHotKey); pobjAction->setShortcut(cobjKeySeq); }
Where clsMainWnd::mscchHotKeyIndicator is set to &.
-
@SPlatten
I don't know about Qt4.Under Qt5 (Ubuntu) I am using
&
s on top-level menu items like:QMenu *fileMenu = menuBar()->addMenu("&File");
and that works --- Alt+F triggers it.
I do not find that
&
s on the menu items that drop down from this respond to Alt, e.g. when I follow the above line withfileMenu->addAction("&Clear", this, &MainWindow::actionClear);
the item does show with the
C
underscored but Alt+C does not trigger it.However, FWIW, for another menu I have:
QMenu *solveMenu = menuBar()->addMenu("&Solve"); solveMenu->addAction("St&ep", this, &MainWindow::actionSolveStep, QKeySequence(Qt::CTRL + Qt::Key_E));
that item shows as Step Ctrl+E and I do find that clicking Ctrl+E triggers it.
That's what I know!
-
@JonB , thank you, I've done this with:
int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator)); if ( intHotKeyIdx >= 0 ) { const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1)); const QKeySequence cobjKeySeq(cstrHotKey); pobjAction->setShortcut(cobjKeySeq); }
Where clsMainWnd::mscchHotKeyIndicator is set to &.
-
@SPlatten
To close this thread then. You are a good/native English speaker, are you not? Would you therefore care to correct your topic title which includesset hotkey's [sic.] that work
to be grammatically correct and not offend those of us who think that punctuation rules are there to be obeyed correctly? ;-)
-
@JonB , being just a young 52 year old British born and English speaking person, I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.
In Windows setting the text with an & in the text before the hot key is enough to get the hot get working, in Linux it isn't so the subject is perfectly correct.
-
@SPlatten said in How to set hotkey's that work in Linux?:
I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.
OMG, really?!
Grammar has nothing to do with "accurately describes the problem".
Do you really think your
hotkey's
is correct?? You think that is how to write the plural of the wordhotkey
?! :) -
@J-Hilk
Not sure what you mean. But if I really need to spell it out it should beHow to set hotkeys that work in Linux?
hotkeys
is the plural ofhotkey
.hotkey's
is a possessive, referring to something which "belongs to" onehoykey
, likethe hotkey's action
. Andhotkeys'
is also a possessive, referring to something belonging to multiple hotkeys, likeall the hotkeys' actions
.If you don't like the
that
,How to set hotkeys which work in Linux?
would be equally acceptable, possibly marginally preferable.
Here endeth the lesson. I do not wish to carp over spelling/grammar in English, but I would expect my colleague @SPlatten to be aware of this. The world is going to the dogs! No offence to anyone intended :)
P.S.
Go read Eats, Shoots & Leaves if you want to understand why punctuation rules can be so important in English. [No pandas were harmed in the writing of that book!]