Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.6.2, 5.8.0
-
None
-
macOS Sierra, Qt 5.8 SDK
Description
A QWidgetAction set in a menu submenu is missing initial widget update when the menu action owning it is shown.
This result in a not rendered widget content in the sub menu.
Notice that the first time the menu bar is triggered it works fine, then if you hover others actions and back to the widget one, it's not updated anymore.
This problem seems to appear on macOS only.
Steps to reproduce:
1- Start the testcase
2- Hover the View > LE submenu with mouse
3- The lineedit is shown correctly
4- Close the menu bar and repeat step 2
5- The lineedit is no more repainted correctly
If you uncomment the connect() in the test case, then the widget action is working correctly in all case.
#include <QtWidgets> class Window : public QMainWindow { public: Window(QWidget *parent = nullptr) : QMainWindow(parent) { QWidgetAction *leAction = new QWidgetAction(this); leAction->setDefaultWidget(new QLineEdit); QMenu *view = menuBar()->addMenu("View"); view->addAction("1"); view->addAction("2"); view->addSeparator(); QMenu *custom = view->addMenu("LE"); //#if defined(Q_OS_MAC) // // Workaround // connect(custom, &QMenu::aboutToShow, // leAction->defaultWidget(), static_cast<void (QWidget::*)()>(&QWidget::update)); //#endif custom->addAction(leAction); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Window window; window.show(); return app.exec(); }