PDA

View Full Version : howto dynamically remove/delete child widgets



sepp
22nd February 2006, 13:49
hi all,

i'm working on a sort of thumbnail image viewer. each time a new folder is selected, images from that folder are read into QImages and are displayed via QLabels. these QLabels are childs of a normal widget i use as a sort of canvas to display the thumbs.

my question is as follows:
if i have let's say an initial directory containing 500 images, i'll have a container with 500 QLabels to display. if i switch to another directory with lets say only 100 images, can i get rid of the 400 QLabels i don't need? of course, i could hide() them, but can i call delete on them if they are constructed with a parent widget? (that is, if the QWidget is a child, does the dtor inform the parent that the child is about to be deleted? from the open src qwidget.cpp, it doesn't seem so...)

thanks

sepp

wysota
22nd February 2006, 14:14
You may safely delete them. A deleted item detatches itself from the parent.

sepp
22nd February 2006, 15:58
thanks

sepp