Qt 6.11 is out! See what's new in the release
blog
[Solved] Should call destructor after QList<CustomObjectPointer *> when call "remove" methods?
General and Desktop
3
Posts
2
Posters
1.2k
Views
1
Watching
-
If we have a QList managing pointers to custom objects class, when we call remove methods:
@
QList <CustomClass > lines; //Declaration.
/******************/
//Call to remove:
lines.removeLast();
@Should I call delete(object Im going to remove) before call lines.removeLast(), or It's called automatically when removeLast() is invoked?
Ty
-----------------------EDIT------------------------
Yes, It's necessary. Otherwise, parent item will still drawing it, if it's a customized QGraphicsItem.
-
Hi, seems takeLast is more suitable for you.
@
delete lines.takeLast();
@