Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60424

QWidgetAction in submenu miss initial update

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.10.0
    • 5.6.2, 5.8.0
    • None
    • macOS Sierra, Qt 5.8 SDK
    • macOS

    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();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            filipe.azevedo Filipe Azevedo
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes