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

QMenu are shown at the wrong location in a QGraphicsScene

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.3.2, 5.4.2, 5.5.0
    • Widgets: GraphicsView
    • None
    • Windows 7, GNU/Linux

      When having one or multiple QMenu embedded inside a QGraphicsScene (or as children of an embedded widget) they are sometimes not shown at the right position when opened. Also, the transition from one opened menu to another without clicking, in a QMenuBar for instance, does not work.

      Code to reproduce :

      #include <QApplication>
      #include <QMenu>
      #include <QMenuBar>
      #include <QGraphicsScene>
      #include <QGraphicsView>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QMenuBar* bar = new QMenuBar;
          // Populate :
          QMenu* a1 = bar->addMenu("a1");
          a1->addMenu("b1")->addAction("c1");
          a1->addMenu("b2")->addAction("c2");
          QMenu* a2 = bar->addMenu("a2");
          a2->addMenu("b1")->addAction("c1");
          a2->addMenu("b2")->addAction("c2");
          QGraphicsScene scene;
          QGraphicsProxyWidget* proxy = scene.addWidget(bar);
      
          QGraphicsView graphicsView;
          graphicsView.setScene(&scene);
      
          // To get a larger window :
          //graphicsView.setSceneRect(0, 0, 500, 500);
          //graphicsView.resize(512, 512);
          graphicsView.show();
      
          return app.exec();
      }
      

      The documentation of QGraphicsProxyWidget has the following warning :
      "This only works if the popup is child of the embedded widget". If it applies to the previous example, it would be nice to have more details in the documentation about it then.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ronan-kerviche Ronan Kerviche
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes