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

If a menu has a submenu then QMenu::show() shows it in the wrong position on Mac

    XMLWordPrintable

Details

    • macOS
    • a39c5321bd812e3ce820fabd6a97eaf8a6c3d01c

    Description

      If we set an menu active action (QMenu::setActiveAction) to an item which is a submenu and then call QMenu::show then the submenu will be shown in the wrong position.

      It happens only on Mac.

      here is an example or you can modify the tst_qmenu::activeSubMenuPosition to call show() instead of popup()

      Test case main.cpp to reproduce
      ===============================
      #include <QtGui>

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

      QLabel lab("test");
      lab.show();

      QAction *tmp = 0;

      QMenu *sub = new QMenu("Submenu", &lab);
      sub->addAction("Sub-Item1");
      QAction *tmp2 = sub->addAction("Sub-Item2");

      QMenu *main = new QMenu("Menu-Title", &lab);
      (void)main->addAction("Item 1");
      QAction *ac2 = main->addMenu(sub);
      tmp = main->addAction("Item 3");
      (void)main->addAction("Item 4");

      tmp = ac2;
      main->setActiveAction(tmp);
      sub->setActiveAction(tmp2);
      //main->move(QPoint(500,500)); // this fixes the problem.
      main->show();

      return app.exec();
      }

      Attachments

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

        Activity

          People

            richard Richard Moe Gustavsen
            dzyubenk Denis Dzyubenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes