How can I add resizable widget开发者_StackOverflow中文版s 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();
}
You must use layouts if you want that your widgets are resizable: http://doc.qt.io/qt-5/layout.html
精彩评论