QVBoxLayout 类垂直排列 Widget。 更多...
头: | #include <QVBoxLayout> |
qmake: | QT += widgets |
继承: | QBoxLayout |
QVBoxLayout (QWidget * parent ) | |
QVBoxLayout () | |
virtual | ~QVBoxLayout () |
此类用于构造垂直框布局对象。见 QBoxLayout 了解细节。
类的最简单用法像这样:
QWidget *window = new QWidget; QPushButton *button1 = new QPushButton("One"); QPushButton *button2 = new QPushButton("Two"); QPushButton *button3 = new QPushButton("Three"); QPushButton *button4 = new QPushButton("Four"); QPushButton *button5 = new QPushButton("Five"); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(button1); layout->addWidget(button2); layout->addWidget(button3); layout->addWidget(button4); layout->addWidget(button5); window->setLayout(layout); window->show();
First, we create the widgets we want in the layout. Then, we create the QVBoxLayout object and add the widgets into the layout. Finally, we call
QWidget::setLayout
() to install the QVBoxLayout object onto the widget. At that point, the widgets in the layout are reparented to have
window
作为其父级。
另请参阅 QHBoxLayout , QGridLayout , QStackedLayout , 布局管理 ,和 基本布局范例 .
构造新的顶层垂直框采用父级 parent .
构造新的垂直框。必须将它添加到另一布局。
[virtual]
QVBoxLayout::
~QVBoxLayout
()
销毁此框布局。
布局的 Widget 不被销毁。