Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.7
-
None
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()