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

QToolButton popup menu is shown at wrong position when embedded in a QGraphicsView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.0
    • 4.4.3
    • Widgets: GraphicsView
    • None
    • a210a1efb3a255235ab22e618c61d0aaccba3d9f

    Description

      When having a QToolButton with a menu embedded in a QGraphicsView then the menu may be popped up in the wrong location depending on the position of the tool button in the scene.


      Example:

      #include <QtGui>
      
      class widget : public QGraphicsView
      {
      public:
          widget(QWidget* parent = 0)
              : QGraphicsView(parent)
          {
              QGraphicsScene* scene = new QGraphicsScene(0, 0, 6000, 6000, this);
              setScene(scene);
      
              QToolButton* tb = new QToolButton;
              tb->setText("...");
              QMenu* menu = new QMenu("&File");
              menu->addAction("hello");
              tb->setPopupMode(QToolButton::MenuButtonPopup);
              tb->setMenu(menu);
      
              QGraphicsProxyWidget* proxy = scene->addWidget(tb);
              tb->move(5900, 10);
              tb->show();
          }
      };
      
      int main(int argc, char **argv)
      {
          QApplication a(argc, argv);
          widget w;
          w.show();
          return a.exec();
      }
      

      The problem also occurs with menus added to embedded QPushButtons:

      #include <QtGui> 
      
      class widget : public QGraphicsView 
      { 
      public: 
      widget(QWidget* parent = 0) 
      : QGraphicsView(parent) 
      { 
      QGraphicsScene* scene = new QGraphicsScene(); 
      setScene(scene); 
      
      QMenu * menu = new QMenu(); 
      menu->addAction( "foo" ); 
      
      QPushButton * button = new QPushButton( "Push Me" ); 
      button->setMenu( menu ); 
      
      QGraphicsProxyWidget* proxy = scene->addWidget(button); 
      button->show(); 
      } 
      }; 
      
      int main(int argc, char **argv) 
      { 
      QApplication a(argc, argv); 
      widget w; 
      w.show(); 
      return a.exec(); 
      } 
      

      Attachments

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

        Activity

          People

            menard Alexis Menard (closed Nokia identity) (Inactive)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes