Parents of (Tab)Widgets when using Eclipse QT Plugin
I'm very new to QT, but used to Eclipse, so I love the Eclipse QT Plugin, but now here is something I don't understand and I was hoping you could help me:
My understanding of the plugin so far is, that I click together my gui, which is saved in an XML file (say: myprog.xml) and by some higher magic transformed into C++ code (ui_myprog.h) that describes where to put the elements and what to do with them.
I have a simple application containing a QTabWidget that has 2 tabs, containing my own Widgets called InputTab and PreprocessingTab. When I look in the automatically created ui_myprog.h, it creates this QTabWidget like this:
Code:
tabWidget
->setObjectName
(QString::fromUtf8("tabWidget"));
tabWidget
->setGeometry
(QRect(0,
0,
1011,
781));
inputTab = new InputTab();
inputTab
->setObjectName
(QString::fromUtf8("inputTab"));
tabWidget
->addTab
(inputTab,
QString());
preprocessingTab = new PreprocessingTab();
preprocessingTab
->setObjectName
(QString::fromUtf8("preprocessingTab"));
tabWidget
->addTab
(preprocessingTab,
QString());
My own class for InputTab has a predefined constructor like this:
and I found out that it is indeed constructed without a parent. However, later in other methods of InputTab I am able to access its parent (the QTabWidget) and its grandparent (MyProg). However, I don't see where the parent was set. This should be done in ui_myprog.h, but I see nothing like this. I observed this problem when I was trying to access the parent in the constructor, where it is still undefined. Now I wonder what I have to do to make sure the parent really is set. Would be great if someone could help me out :-/
Re: Parents of (Tab)Widgets when using Eclipse QT Plugin
Quote:
Code:
tabWidget
->addTab
(inputTab,
QString());
tabWidget
->addTab
(preprocessingTab,
QString());
When you insert the widget into a QTabWidget, QTabWidget takes ownership (becomes parent) of the widget (which is inputTab/preprocessingTab in your case)
Re: Parents of (Tab)Widgets when using Eclipse QT Plugin
Ah, that explains a lot ... thank you!!