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

Right click context menu in Graphics View clears rubberband selection.

XMLWordPrintable

      It can make things quite unusable if the context menu has actions to operate on the selection.

      The following example demonstrates the problem:

      #include <QtGui>
       int main( int argc, char** argv ){
          QApplication app( argc, argv );
          //give a seed for the pseudo-random generator
          qsrand(QTime::currentTime().msecsTo(QTime(0,0,0)));
      
          QGraphicsView view;
          QGraphicsScene *scene = new QGraphicsScene(0, 0, 320, 240);
          QAbstractGraphicsShapeItem *gi;
          for (int i = 0; i< 12; ++i ) {
              QColor color = QColor::fromHsv(((qrand()%12)*30), 255, 255);
              QRectF itemRect(qrand()%270, qrand()%190, (10 * (qrand() % 4 + 1)), (10*(qrand() % 4 + 1)));
              if (!(i%3))
                  gi = new QGraphicsEllipseItem(itemRect);
              else
                  gi = new QGraphicsRectItem(itemRect);
              gi->setBrush(color);
      
              gi->setFlags(QGraphicsItem::ItemIsSelectable);
              scene->addItem(gi);
          }
      
          view.setRenderHints(QPainter::Antialiasing);
          view.setDragMode(QGraphicsView::RubberBandDrag);
          view.setContextMenuPolicy(Qt::ActionsContextMenu);
          view.addAction(new QAction("dummy 1",&view));
          view.addAction(new QAction("dummy 2", &view));
          view.setMouseTracking(true);
      
          view.setScene(scene);
          view.scale(2,2);
          view.resize(680,500);
          view.show();
      
          return app.exec();
      }
      

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

            ylopes Yoann Lopes
            ntg Pierre Rossi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes