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

QGraphicsView::translate() does nothing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • Some future release
    • 3.x, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.3.0, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.6.0, 4.7.0, 4.7.1, 5.0.0, Some future release
    • Widgets: GraphicsView
    • None

      It seems QGraphicsView::translate() has no effect. You would expect it to shift the scene around, but it has no visual impact at all.

      This (broken) behavior has been stable since 4.2. Rotating and scaling works as expected.

      See the following example:

      #include <QtGui>
      
      class Widget : public QWidget
      {
          Q_OBJECT
      public:
          Widget()
          {
              scene.addRect(0, 0, 100, 100);
              scene.addRect(25, 25, 50, 50);
      
              QVBoxLayout *layout = new QVBoxLayout;
              view = new QGraphicsView(&scene);
              layout->addWidget(view);
              QPushButton *button = new QPushButton;
              layout->addWidget(button);
              setLayout(layout);
      
              connect(button, SIGNAL(clicked()), this, SLOT(translate()));
      
              // the two lines below have no effect on the translation
              view->setTransformationAnchor(QGraphicsView::NoAnchor);
              view->setResizeAnchor(QGraphicsView::NoAnchor);
          }
      
      private slots:
          void translate()
          {
              view->translate(25, 0);
          }
      
      private:
          QGraphicsScene scene;
          QGraphicsView *view;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          Widget widget;
          widget.show();
      
          return app.exec();
      }
      
      #include "main.moc"
      

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

            ylopes Yoann Lopes
            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes