[edit]
Please ignore, this has been "solved". The problem wasn't qtcreator, it was my stupidity! Although the parent isn't explicitly set at the point of instantiation, it is set when calling addWidget, which eventually makes its way to the addChildWidget method in http://qt.gitorious.org/qt/qt/blobs/...el/qlayout.cpp
Maybe I was casting incorrectly, which may explain why it wasn't working before, but it seems fine now. Sorry for wasting your time.
Hi,
I'm using QtCreator to build the UI for my project. I've got a QStackedWidget object in my mainwindow and each "layer", or "page", of the stacked widget has been promoted to a custom class, derived from QWidget. Note, I've also done something similar for a wizard in my project, where each wizard page has been promoted to a custom class.
The problem is, although the classes are derived from QWidget (and qtcreator knows this), the generated code isn't passing a parent into the constructor of the promoted class on instantiation. It's not even using the setParent method after instantiation.
If I understand correctly (I'm a C++ newbie, feel free to correct me), it means that I will have a memory leak because I'm not deleting these objects and they don't have a parent and thus won't be deleted automatically either. It also means I can't get a reference to the parent object.
I know I could find a pointer or reference to my objects and manually call setParent, but is there any automated way of telling qtcreator to pass a parent object on instantiation (or at least call the setParent method after instantiation on objects that are derived from QObject)?
Thanks!
Bookmarks