c++ - Qt Extending my own widget -
To put it simply, I want a new class that increases the custom widget I created, and thus There is full access to this UI.
I have tried many different ways till now, how would normally sub-classes / extend classes, but I have in any way been for many reasons I have failed miserably.
In addition, just do not use my widget as a member in my new category for this situation.
Can anyone tell me how do I do this? I've done a bunch of searches but I can not seem to find any hits related to what I'm actually trying to do if everything goes wrong so I'll just copy the code and make a real Create a new widget, which will be technically saved, it takes a lot of time, but it is not doing it properly.
My first trend was to do something like this ( Qwe
being my new class, asd
widget):
< Code> class Q: ASD {public: ...}
And I have also created the U public, but then I just get an error:
< P> UI :: ASD
Use the undefined type whenever I tried to reach the elements of U.
ChildWidget
. Normally declare BaseWidget
, but preserve your UI
member instead of private, such as: protected: UI :: baseview * UI; Declare as a simple widget generated from ChildWidget
to BaseWidget
. Make sure that you are included in the ui_BaseWidget.h
file in the ChildWidget.cpp
file, as you do it in BaseWidget.cpp
(includes And the header itself is generated by QT).
Header:
#include "BaseWidget.h" Category ChildWidget: Public BaseWidget {Q_OBJECT Public: Clear ChildWidget (QString text, QWidget * parent = 0); };
source:
#include "ChildWidget.h" ## "ui_BaseWidget.h" ChildWidget :: ChildWidget (QString Text, QWidget * Basic) included Do: Basewitz (Parents) {ui- & gt; Label-> Set text (text); }
Comments
Post a Comment