[PyKDE] Dynamic layouts
Boudewijn Rempt
boud at rempt.xs4all.nl
Thu Mar 15 07:17:33 GMT 2001
On Wednesday 14 March 2001 21:39, you wrote:
> Boudewijn,
>
> I had trouble with removing/adding widgets to layouts too. FWIW, here are
> some things that worked for my situation. Note: I was using Qt 1.44, so
> some of this might be out of date.
>
> I gave up on using HBox and VBox layouts. Instead, I used GridLayouts with
> only one row/column. The advantage is that you can directly access specific
> cells. The disadvantage is that you have to use addWidget and addLayout to
> insert insert the contents. You have to do more of your own bookkeeping,
> but you have more control.
>
> For my application, I kept python references to the widgets in the layout
> cells. When I wanted to change a widget, I first unreferenced it
> (self.myWidget = None). The Qt destructors automatically remove deleted
> widgets from any layouts in which they appear (I'm sure I saw this in the
> Qt docs somewhere, but I can't find the reference right now). Then I
> created a new one and used addWidget to add it to the now-empty cell.
>
> Hope that helps.
>
>
Well, I tried using QLayout classes, too, and keeping Python references, too.
However, setting those references to None didnn't remove the widgets, since
there are still references from the parent widget (QMainWindow) and from the
QLayoutItems. I think that this PyQt behaviour is relatively new.
--
Boudewijn Rempt | http://www.valdyas.org
More information about the PyQt
mailing list