How does QSpacerItem get deleted?
alogim last edited by alogim
So, I know usually objects get deleted in Qt when their parents gets deleted. What about
QSpacerItem, for example?
Since it is not possible to set its parent, how does it get deleted if I write
spacerItem = new QSpacerItem(10, 10);
spacerItemis declared in a
.hfile? Do I have to take care of deletions by myself?
alogim last edited by
@kshegunov Thank you very much, I missed that on the docs :)
Now all makes sense, thank you again.
As an additional note:
If you wish to delete an item that's been held by a layout, you should detach it first by using QLayout::takeAt. Then the ownership of the item will no longer belong to the layout, so you can safely delete it. You should take care not to delete the item if it's handled by a layout.
To add to @kshegunov, if you don't use
spacerItemin any layout (very unlikely but still) then it's your job to delete it.
This actually was my first post's point ;)
@kshegunov Err… I somehow managed to misread that last statement :D
It happens even to the best ... at the very least we both support it, so that has to account for something ;)