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

QGraphicsProxyWidget ignores sizeHint of widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.6.2, 4.7.0
    • Widgets: GraphicsView
    • None

    Description

      QGraphicsProxyWidget::effectiveSizeHint() ignores changes to the sizeHint() of the widget that the proxy contains. This causes trouble, because effectiveSizeHint() is used by QGraphicsLayout.
      This can not be fixed by the user "directly", because QGraphicsWidget::updateGeometry() (and therefore QGraphicsProxyWidget::updateGeometry()) is marked as protected, although it was public in QGraphicsLayoutItem.
      Note that casting the pointer to QGraphicsLayoutItem and then calling updateGeometry() on it fixes the problem.

      The issue can be observerd in the attached sample code. Here a QLabel with an initial text is created and embedded into a QGraphicsProxyWidget. This proxy is displayed using a QGraphicsGridLayout. The initial text of the label is displayed correctly, however when the size of the label changes, the proxy (and thus the QGraphicsGridLayout) is not updated. Furthermore the user cannot call updateGeometry() on the proxy after changing the text, because it is protected.

      The cause of the problem is that QGraphicsLayoutItem::effectiveSizeHints() (used by effectiveSizeHint()) caches the sizeHint of the item. The cache is only updated when updateGeometry() is called, but that function is protected in QGraphicsProxyWidget.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            b_mann Andreas Beckermann
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes