Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Designing a custom widget
I was wondering if in general it's better to design a custom widget containing a pointer for each sub widget/layout allocated in the heap or gather the various pointers using QWidget methods and allocate sub widget only inside methods, taking advantage of parent/child relations, without having a direct reference to them.
In particular, in my custom widget I need to add and remove specific widgets.
@Daniel_Contro If you need to access the widgets later then it is better to store the pointers as members in your class.
@jsulm Even if the insert/remove of widgets would occur only upon mouse events? I would then use childAt(event->pos()) to gather the pointer and not the member in the class.
@Daniel_Contro Well, if your UI is so dynamic then you can of course use childAt, but keep in mind that it is not very fast (you should not call it in long lasting loops for example).
@jsulm Ok, thanks a lot for the help