QList<QLabel *> static or dynamic?
-
I use QList<QLabel *> list as a class member.
I'm gonna add and remove elements in it, so shall I create it statically or dynamically? -
Ecxuse me)
I mean, shall I declare class member QList<QLabel *> * list and use operator new to create list, or shall I just declare QList<QLabel *> list and work with it (work == add and remove items in class member list)?p.s. if not clear, give notice.
-
Definitively, keep working with a single QList, as it is. You don't need a pointer here.
As a general rule, don't use pointers with classes like QList, QString, QByteArray, except if you REALLY need it.
It just works ouf of the box, and then you prevent yourself from memory leaks. A pointer to a QList needs to be explicitely deleted, since it doesn't have a QObject parent.
-
great. thank you for your replies.)