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

QGraphicsScene: If a QGraphicsItem is hidden when added to scene it never gets a polish event

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.1
    • 4.5.0
    • Widgets: GraphicsView
    • None
    • 162071d2651645358a0935b27af8a3b47474a10f

    Description

      If a graphics item is hidden when added to scene it never gets a polish event.

      void QGraphicsScene::addItem(QGraphicsItem *item)
      {
      ...
      if (!item->d_ptr->explicitlyHidden)

      { if (d->unpolishedItems.isEmpty()) QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); d->unpolishedItems << item; }

      ...
      }

      Hidden items never get added to "unpolishedItems" list and thus never get the polish event.

      QGraphicsWidget::polishEvent documentation says:

      "This event is delivered to the item by the scene at some point after it has been constructed, but before it is shown or otherwise accessed through the scene. You can use this event handler to do last-minute initializations of the widget which require the item to be fully constructed."

      But when I call "show" to a widget that was initially hidden I never gets the polish event.

      Attachments

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

        Activity

          People

            ylopes Yoann Lopes
            xcm Martin Petersson (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