BoxLayout 布局
最后更新于:2022-04-02 02:12:07
[TOC]
## QBoxLayout
```
QBoxLayout::LeftToRight
QBoxLayout::RightToLeft
QBoxLayout::TopToBottom
QBoxLayout::BottomToTop
```
## QHBoxLayout 水平布局
```
QWidget *window = new QWidget;
QPushButton *button1 = new QPushButton("One");
QPushButton *button2 = new QPushButton("Two");
QPushButton *button3 = new QPushButton("Three");
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
window->setLayout(layout);
window->show();
```
### QVBoxLayout 垂直布局
```
QWidget *window = new QWidget;
QPushButton *button1 = new QPushButton("One");
QPushButton *button2 = new QPushButton("Two");
QPushButton *button3 = new QPushButton("Three");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
window->setLayout(layout);
window->show();
```
';