I have an application that replaces a layout in PyQt5 using takeAt. I verify that the layout is replaced however, the old layout remains "ghosted" in the application (see image). The ghosted layout widgets are not functional, so they may only be indeed ghost images. Any idea what I'm doing wrong. You can see in the code I've tried to trigger an update unsuccessfully.
Below is the code:
def refreshSelection (self):
parent = self.selection.parent ()
print (parent.children ())
if parent == None:
return
old = parent.takeAt (0)
print (old)
print (parent.children ())
del old
new = self.getDataStreamSelection (self.session)
parent.insertLayout (0, new)
self.selection = new
print (parent.children ())
parent.update ()
parent.parentWidget ().repaint (parent.parentWidget ().rect ())
The output:
[<PyQt5.QtWidgets.QVBoxLayout object at 0x132071690>, <PyQt5.QtWidgets.QVBoxLayout object at 0x13207bd70>]
<PyQt5.QtWidgets.QVBoxLayout object at 0x132071690>
[<PyQt5.QtWidgets.QVBoxLayout object at 0x13207bd70>]
[<PyQt5.QtWidgets.QVBoxLayout object at 0x13207bd70>, <PyQt5.QtWidgets.QVBoxLayout object at 0x13748d0f0>]
You can see the layout is replaced in the children.
Below is an image of the result. I've stretched the window after the replacement so the old version ghost remains unstretched on the left, while the new version is partly stretched and partly in a lighter gray where it no longer fully overlaps. The boxes are in the layout. The black part is the second layout that is not affected by the change.
My platform is MacOS
Python 3.7.4
PyQt5 version 5.13.1
Qt5 version 5.12.5
I've also tested this no Linux to the same effect.
I would appreciate any help