How can i resize QVBoxLayout to fill Form without space?
How can i resize QVBoxLayout to fill Form without space?
with space: http://0000.2.img98.net/ou开发者_开发知识库t.php/i25106_with-space.png
without space: http://0000.2.img98.net/out.php/i25107_without-space.png
You have to set margins for layout
example:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QVBoxLayout* l = new QVBoxLayout();
l->setMargin(0); ///m
QWidget w; w.setFixedSize(300,300);
w.setLayout(l);
l->addWidget(new QPushButton("fd"));
w.show();
return app.exec();
}
You need to adjust the size policy of the widgets contained in the layout.
For example, if you want a widget to take up all the available vertical space in a layout, set the widget's size policy to Expanding
.
Go to the project folder and find the xml file which you cannot edit under Qt Creator. You will find the margin xml tag. Increase or decrease the value as you need. The xml file cannot be edited under Qt Creator.
精彩评论