如何在Qt Creator中添加可调整尺寸的小部件? [英] How can I add resizable widgets in Qt Creator?
本文介绍了如何在Qt Creator中添加可调整尺寸的小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Qt Creator中添加可调整尺寸的小部件?
How can I add resizable widgets in Qt Creator?
QVBoxLayout
c> QHBoxLayout
Specially widgets in QVBoxLayout
or QHBoxLayout
推荐答案
示例:
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();
}
这篇关于如何在Qt Creator中添加可调整尺寸的小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文