How can I add resizable widgets in Qt Creator?
Specially widgets in QVBoxLayout
or QHBoxLayout
Example:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget* w = new QWidget;
QVBoxLayout* l = new QVBoxLayout;
w->setLayout(l);
QPushButton* b = new QPushButton("hello");
b->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
l->addWidget(b);
w->show();
return app.exec();
}
如果您想调整小部件的大小,则必须使用布局: http : //doc.qt.io/qt-5/layout.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.