c++ - Creating a Qt widget belonging to another widget made with Qt Designer -


i have created label in mainwindow.cpp

lblmylabel = new qlabel(this); 

what put in place of "this" in order have show in layout created qt designer?

i know silly question simple answer open lot of doors me far understanding how works.

for example can try following.

first shall add qwidget want qlabel displayed in widget created in designer. , after try following lines:

void setmainwidget( qwidget* aparent, qwidget* achild, const int amargin = 0 ) {     qgridlayout* layout = new qgridlayout( aparent );     layout->addwidget( achild );     layout->setmargin( amargin );     aparent->setlayout( layout ); } 

in case:

mylabel = new qlabel( ui->widget ); setmainwidget( ui->widget, mylabel ); 

it useful more complex custom widgets.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -