Problem with QAction's shortcut and QMenu
-
When i add an action to a QMenu, wich is added to QMenuBar() in QMainWindow, the QAction's shortcut works fine. But, when i do:
@QMenuBar()->hide()@
the shortcut doesn't answer anymore, any idea? -
You are right Gerolf, the actions added to the toolbar still answering to the shortcut. What do you suggest to fix that?
-
If an action is completely hidden, it is disabled. If you need global shortcuts, event when the actions UI stuff is hidden, us "QShortcut":http://doc.qt.nokia.com/4.7/qshortcut.html
@
shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated ()), this, SLOT(fileOpen()));
@ -
yeah, that works, and i've done something like that, but then if the menu is visible (hiding and showing is done by the user) i get to another problem:
@QAction::eventFilter: Ambiguous shortcut overload: Ctrl+O@
and the only thing comes to my mind is to implement something that manage the shortcuts according to the menu state, what's your opinion about that? -
yes, i can do that too, but it's going to be a pain in the a** since i need to consider wich action is in the toolbar (also configurable in the ui) :-P
anyway, thanks you for answering so fast.