Removing items from a QGraphicsLinearLayout works in a way that may seem counterintuitive to many: when using the removeAt() or removeItem() methods, the item is removed from the layout, but it is not removed from the scene. This means that the item will still be shown, though its size and position won't be managed by the layout anymore. For the same reason, the item won't be removed from the list of its parent's children. # This won't actually make the item disappear layout.removeAt(2) However, if we get a reference to the item using itemAt() and we assign it to a variable, the removal will have a different behavior. The item is actually removed from the list of children of its parent. # This will remove the item from the layout and make it disappear w = layout.itemAt(2) layout.removeAt(2) Warning: the detachment from the parent happens when control goes back to the loop, not before that. To make a long story short, due to this PyQt4 bug, doing: w = layout.itemAt(2) layout.removeAt(2) is the same of: layout.removeAt(2) del layout.itemAt(2) that equals to: del layout.itemAt(2) The attached patch fixes the issue. Reproducible: Always
Created attachment 200481 [details, diff] QGraphicsLinearLayout children widgets patch
Have you reported the issue upstream?
I always do, but never gotten a single answer.
(In reply to comment #3) > I always do, but never gotten a single answer. > Phil always responds to my e-mails I use this e-mail phil[at]riverbankcomputing.com to contact him
Just mailed Phil pointing him to this bug ;) Thanks a lot
Patch applied on latest PyQt4 snapshot by upstream I applied this patch on PyQt4-4.5.4-r3 as well Thanks Fabio +*PyQt4-4.5.4-r3 (12 Aug 2009) + + 12 Aug 2009; Markos Chandras <hwoarang@gentoo.org> -PyQt4-4.5.4-r1.ebuild, + +PyQt4-4.5.4-r3.ebuild, + +files/PyQt4-4.5.4-qgraphicslinearlayout-fix.patch: + Added patch for removing items from QGraphicsLinearLayout. Fixes bug + 280634 . + THanks to Fabio Erculiani <lxnay@sabayonlinux.org> for the patch +