The QHBoxLayout 類水平排列 Widget。 更多...
| 頭: | #include <QHBoxLayout> |
| qmake: | QT += widgets |
| 繼承: | QBoxLayout |
| QHBoxLayout () | |
| QHBoxLayout (QWidget * parent ) | |
| virtual | ~QHBoxLayout () |
| const QMetaObject | staticMetaObject |
The QHBoxLayout 類水平排列 Widget。
此類用於構造水平框布局對象。見 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");
QHBoxLayout *layout = new QHBoxLayout(window);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->show();
First, we create the widgets we want to add to the layout. Then, we create the
QHBoxLayout
object, setting
window
作為父級通過將它傳入構造函數;接下來,將 Widget 添加到布局。
window
將是被添加到布局的 Widget 父級。
If you don't pass parent
window
in the constrcutor, you can at a later point use
QWidget::setLayout
() 安裝
QHBoxLayout
object onto
window
。此時,布局中的 Widget 被重設父級以讓
window
作為其父級。
另請參閱 QVBoxLayout , QGridLayout , QStackedLayout , 布局管理 ,和 基本布局範例 .
構造新的水平框。必須把它添加到另一布局。
構造新的頂層水平框采用父級 parent .
將直接把布局設為頂層布局對於 parent 。Widget 隻可以有一個頂層布局。返迴它通過 QWidget::layout ().
另請參閱 QWidget::setLayout ().
[虛擬]
QHBoxLayout::
~QHBoxLayout
()
銷毀此框布局。
不銷毀布局 Widget。