c++ - How to programmatically add a Qt widget (QPushButton, QTextEdit, QLabel) to a Qt Designer layout? -


is possible dynamically add widgets (pushbuttons, labels, etc.), qt designer-generated central widget layout? how can done?

thank you!

of course, , it's quite easy. can have @ ui_mainwindow.h @ debug/release dir. prefer setting layouts widgets in qtdesigner code. it's this:

//set layout programatically auto layout = new qhboxlayout(ui->centralwidget());  //or if have set horizontallayout in qt designer auto layout = dynamic_cast<qhboxlayout*>(ui->centralwidget->layout());  layout->addwidget(new qlabel("hello")); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -