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

[REG] QGraphicsItem: cached embedded widget item is not repainted when widget is updated

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.7.1
    • 4.5.1
    • Widgets: GraphicsView
    • None
    • e9d63b7824e9105074dee9ad624582e5894d9c8b

    Description

      A cached embedded widget is not repainted when the widget is updated, if the scene rectangle is explicitly set and the widget update happens just after an item has been removed from the scene (for example an editor in an embedded item view or an embedded context menu).

      This is a regression from Qt 4.4.

      The problem does not occur if the scene rectangle is not explicitly set, if the item is not cached, or if no item is removed from the scene before the embedded widget is updated.

      The following example reproduces the problem:

      #include <QtGui>
      
      class PushButton : public QPushButton
      {
          Q_OBJECT
      
      public:
          PushButton(QWidget *parent = 0) : QPushButton(parent)
          {
              setText("Update the text by clicking me or from my context menu");
      
              setContextMenuPolicy(Qt::ActionsContextMenu);
              QAction *action = new QAction("Update text", this);
              addAction(action);
      
              connect(this, SIGNAL(clicked()), this, SLOT(updateText()));
              connect(action, SIGNAL(triggered()), this, SLOT(updateText()));
          }
      
      public slots:
          void updateText()
          {
              static int count = 0;
              setText(QString("foobar %1").arg(count++));
          }
      };
      
      #include "main.moc"
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          PushButton w;
          w.show();
      
          QGraphicsView view;
          QGraphicsScene *scene = new QGraphicsScene(0, 0, 800, 600);
          QGraphicsProxyWidget *proxy = scene->addWidget(new PushButton);
          proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
          view.setScene(scene);
          view.show();
      
          return app.exec();
      }
      

      Clicking the button repaints the button with the new text as expected, but updating the text from the context menu menu does not result in a repaint.

      Attachments

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

        Activity

          People

            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes