I'm manipulating a lots of QWidget, but I also delete and replace them quite often.
I know that QT keeps a pool of QWidget, just in case they are reloaded again. Is there a way to really delete a QWidget at once?
I'm manipulating a lots of QWidget, but I also delete and replace them quite often.
I know that QT keeps a pool of QWidget, just in case they are reloaded again. Is there a way to really delete a QWidget at once?
There's no widget pool, just their parents that keep references to them.
To delete a widget just call QWidget::deleteLater(), and it will be deleted the next time the event loop gains control.
You can also call delete myWidget; but make sure to also make it null afterwards.
So if I'm creating / deleting a large amount of QWidget and not getting back my memory there is an issue somewhere right ?
Make sure every widget has a parent(that way you know that when deleting a widget all its children will be also deleted) and then check for leaks somewhere else in your program.
You can use a profiler to get some idea about where exactly the leaks are occurring.
bunjee (14th February 2008)
Bookmarks