[SOLVED]Should i Manully delete controls in the MainWindow's destructor?
-
@opengpu2 said:
i create the ui controls setting it's parent to the window?
so should i delelte and set them to NULL in the window's destructor?
or should i do this delete in the window's closeEvent() func?
thank you!posted 22 minutes ago
Neither. If the control has the window as its parent, the window will automatically take care of cleaning it up.
-
how about QGraphicsItem ?
i notice that, when pItem was created, no parent was sent to it, and then just scene->addItem(pItem).
what should i do when i close the widget which contain the QGraphicsView/Scene?
should i delete all the QGraphicsItem in the QGraphicsView's destructor or in closeEvent?
thank you -
@opengpu2 said:
how about QGraphicsItem ?
Yes. If you
addItem
, the parent and ownership is set to the QGraphicsView/Scene. The documentation for these classes describes this. I suggest opening up Qt assistant and reading, the documentation is really terrific. -
thank you.
so u mean, like this:
pItem = new QGraphicsItem( 0 ); //no parent was send here
scene->addItem(pItem);the parent is still the scene.
and when i close the widget which owns the QGraphicsView/Scene.
still no need to Manully delete the pItem, right?