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

QGraphicsGridLayout stops reacting to child visiblity changes if stretch factors are set.

    XMLWordPrintable

Details

    • Windows

    Description

      Setting RowStretchFactor or ColumnStretchFactor on a QGraphicsGridLayout will break the layout. It will no longer update if a child changes visibility. Explicitly calling invalidate() after the child is hidden/shown, will fix it.

      Uncommenting the 2 lines in the example below will show the faulty behaviour.
      (It's in Python, I hope that's OK)

      from PySide6 import QtCore, QtWidgets
      
      app = QtWidgets.QApplication()
      
      button = QtWidgets.QPushButton("Toggle Visibility")
      button.clicked.connect(lambda: b.setVisible(not b.isVisible()))
      a = QtWidgets.QGraphicsProxyWidget()
      a.setWidget(button)
      b = QtWidgets.QGraphicsProxyWidget()
      b.setWidget(QtWidgets.QLabel("Hello World!"))
      
      l = QtWidgets.QGraphicsGridLayout()
      l.addItem(a, 0, 0)
      l.addItem(b, 1, 0)
      # l.setRowStretchFactor(0, 1)
      # l.setRowStretchFactor(1, 1)
      
      w = QtWidgets.QGraphicsWidget(None, QtCore.Qt.WindowType.Window)
      w.setLayout(l)
      
      scene = QtWidgets.QGraphicsScene()
      scene.addItem(w)
      view = QtWidgets.QGraphicsView(scene)
      
      view.show()
      app.exec()
      

      Attachments

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

        Activity

          People

            bibr Andreas Aardal Hanssen
            maxxpower Markus Fleischhacker
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes