GraphicsLayout: Always call layout.activate() after adding items
Items added to a `GraphicsLayout` only learn their size information after the internal `QGraphicsGridLayout` recalculates the layout. This is happening as a slot in the Qt event queue. Not having updated geometry bounds directly after adding an item leads to multiple issues when not executing the Qt event loop in time (see below). This commit fixes that by always calling `layout.activate()` after adding items, updating item sizes directly. This is a follow-up to PR #1167, where introducing a direct call to `processEvents` was suspected to be able to cause side effects. Notifying @j9ac9k and @campagnola, as they were involved in #1167. Fixes #8 Fixes #1136
This commit is contained in:
parent
a2053b13d0
commit
ec66c34fc9
@ -134,6 +134,9 @@ class GraphicsLayout(GraphicsWidget):
|
||||
item.geometryChanged.connect(self._updateItemBorder)
|
||||
|
||||
self.layout.addItem(item, row, col, rowspan, colspan)
|
||||
self.layout.activate() # Update layout, recalculating bounds.
|
||||
# Allows some PyQtGraph features to also work without Qt event loop.
|
||||
|
||||
self.nextColumn()
|
||||
|
||||
def getItem(self, row, col):
|
||||
|
Loading…
Reference in New Issue
Block a user