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

Nested QGraphicsView - No mousePressEvent for right mouse button

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3: Somewhat important
    • Some future release
    • 4.5.3
    • Widgets: GraphicsView
    • None
    • Windows XP 64-bit and Vista 64-bit

    Description

      When nesting QGraphicsViews, the inner QGraphicsView does not get any mousePressEvents for the right mouse button. It though works correctly for the left mouse button. mouseMoveEvent and mouseReleaseEvents are not affected.
      This behavior is observed when the window flag is set to something different than Qt::Widget, i.e., Qt::Dialog. See sample source below.

      class View:
          public QGraphicsView
      {
      public:
             View()
             {
                 setWindowFlags(Qt::Dialog);
             }
             ~View(){}
      
      protected:
      
          void mouseMoveEvent(QMouseEvent *me)
          {
              if (me->buttons() == Qt::LeftButton){
                  cout << "View::mouseMoveEvent -> LeftButton" << endl;
              }else if (me->buttons() == Qt::RightButton){
                  cout << "View::mouseMoveEvent -> RightButton" << endl;          
              }
          }
          void mousePressEvent(QMouseEvent *me)
          {
              if (me->buttons() == Qt::LeftButton){
                  cout << "View::mousePressEvent -> LeftButton" << endl;
              }else if (me->buttons() == Qt::RightButton){
                  cout << "View::mousePressEvent -> RightButton" << endl;          
              }
          }
      
          void mouseReleaseEvent(QMouseEvent *me )
          {
              if (me->button() == Qt::LeftButton){
                  cout << "View::mouseReleaseEvent -> LeftButton" << endl;
              }else if (me->button() == Qt::RightButton){
                  cout << "View::mouseReleaseEvent -> RightButton" << endl;          
              }
          }
           
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QGraphicsView view1;
          View view2;
      
          view1.setScene(new QGraphicsScene());
          view2.setScene(new QGraphicsScene());
      
          view1.scene()->addWidget(&view2);
      
          view1.resize(640, 480);
          view1.show();
      
          return app.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)
            ollie Olivier Saurer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes