Home > Back-end >  Consult about QT this little problem
Consult about QT this little problem

Time:11-29

A is A QWidget object, new in it for an inheritance in QWidget class of object B, B in the function of new again A QPushButton C
Is
In A function of the
QWidget * B=new QWidget (this);
In the function of B
QPushButton * C=new QPushButton (this);

So how can I make C on A Widget shows?

thank you

CodePudding user response:

A need A layout
 
A - & gt; SetLayout (new QVBoxLayout (this));

B need a layout
 
M_pVBLayout=new QVBoxLayout (this);
A - & gt; SetLayout (m_pVBLayout);

QPushButton * C=new QPushButton (this);
M_pVBLayout - & gt; AddWidget (C);

C is displayed

CodePudding user response:

Thank you, I try

CodePudding user response:

Why not directly put the C in A inside? If you want to B to C, this relationship can be placed at the same level to deal with

CodePudding user response:

Both are added this parameter, A C is not in A

CodePudding user response:

QPushButton * C=new QPushButton (this);
Pointer to the parent class C is this namely QWidgets, so start running when the parent window button C is start, hope to adopt ~ ~

CodePudding user response:

Thank you?? Has been resolved!
  • Related