Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.5.0
-
None
-
Win8.1
Description
If you have a QWidgetAction with e.g. a label and a SpinBox and the user is clicking on the label, the menu will be closed. As user I find this behavior strange, because I expect that the menu will be closed, in case it is losing its context or an action is triggered.
My current solution is to catch mousePressEvent and mouseReleaseEvent in default widget of QWidgetAction and accept all events, to prevent this behavior. But this is not really a nice solution because widget inside of QWidgetAction don't should know that it is inside of a QMenu/QWidgetAction and has to catch this events. Alternate would be to overwrite event filter of QWidgetAction (not tested) as far as I can see.
Because all my tested (and popular tools, e.g. options in Office, menu in Firefox, ...) behave differently, it is for me as user an bug - and should be fixed. Compare attached screencasts of qt with Firefox, Opera und PowerPoint. You always see menu will not be closed until I click on something that causes an action, except at where the menu will be always closed.
Source of Qt example:
#include <QApplication> #include <QHBoxLayout> #include <QLabel> #include <QMenu> #include <QMenuBar> #include <QMainWindow> #include <QSpinBox> #include <QWidgetAction> int main(int argc, char * argv[]) { QApplication qapp(argc,argv); QMainWindow mainWindow; auto menuBar = mainWindow.menuBar(); auto menu = menuBar->addMenu("Menu"); auto layout = new QHBoxLayout(); layout->addWidget(new QLabel("Test")); layout->addWidget(new QSpinBox()); auto widget = new QWidget(); widget->setLayout(layout); auto action = new QWidgetAction(menu); action->setDefaultWidget(widget); menu->addAction("Item Before"); menu->addAction(action); menu->addAction("Item After"); mainWindow.show(); qapp.exec(); }