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
Post a Comment