- layout.count() gives you the number of items the layout holds - layout. itemAt(i) gives you the layout item - and if that is not null, then I remove it with layout.removeItem
The rest is up to the garbage collection. If you need to get hold of the actual widget, you can ask the layout item returned by itemAt for it. Cheers Frank > -----Original Message----- > From: Thomas Coopman [mailto:[email protected]] > Sent: Wednesday, April 14, 2010 12:04 PM > To: Frank Bergmann > Cc: [email protected] > Subject: Re: [Qt-jambi-interest] QLayout.dispose() > > Ok, I guess I'll have to do that then. > How do you iterate through the items of the layout? Do you save the items > somewhere or do you ask them from the layout? I don't see any methods to > ask a widget from the layout. > > Thanks > > Thomas > > On Wed, Apr 14, 2010 at 20:04, Frank Bergmann > <[email protected]> wrote: > > I had the same issue ... I settled on iterating through all items of > > the layout and removing it from the layout by calling removeItem > > > > Cheers > > Frank > > > > > >>> Hi, > >>> > >>> I need to write some gui code that add some buttons to a layout. > >>> But now and then these buttons change. So I wrote the code so that > >>> I create a layout for the buttons and then do setLayout to the widget. > >>> Now if the buttons have to be renewed if do > >>> widget.layout().dispose() and again setLayout with the new layout. > >>> But the problem is that the old buttons stay visible. > >> try to simple hide the button with button.hide(). > >> > >> I do something similar but I add all the buttons to the layout and > >> simply > >> show() or hide() the buttons that I need. > >> > >> Try to avoid the dispose() function. > >>> > >>> How can I fix this problem? Is this the correct thing to do, or are > >>> there better ways of doing this? > >>> > >>> Thanks. > >>> > >> _______________________________________________ > >> Qt-jambi-interest mailing list > >> [email protected] > >> http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest > > > > > > _______________________________________________ > > Qt-jambi-interest mailing list > > [email protected] > > http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest > > > > > > -- > Thomas Coopman > [email protected] _______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
