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

QGraphicsView::translate() does nothing

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Out of scope
    • Affects Version/s: 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
    • Fix Version/s: Some future release
    • Component/s: Widgets: GraphicsView
    • Labels:
      None

      Description

      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"
      

        Attachments

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

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes