开发者

How can I add resizable widgets in Qt Creator?

开发者 https://www.devze.com 2023-03-31 07:48 出处:网络
How can I add resizable widget开发者_StackOverflow中文版s in Qt Creator? Specially widgets in QVBoxLayout or QHBoxLayoutExample:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消