QVBoxLayout Class
A classe QVBoxLayout alinha widgets verticalmente. Mais...
| Cabeçalho: | #include <QVBoxLayout> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Herdado de: | QBoxLayout |
Funções públicas
| QVBoxLayout() | |
| QVBoxLayout(QWidget *parent) | |
| virtual | ~QVBoxLayout() |
Descrição detalhada
Esta classe é usada para construir objetos de layout em caixa vertical. Consulte QBoxLayout para obter detalhes.
A forma mais simples de usar a classe é assim:
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(window);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->show();Primeiro, criamos os widgets que queremos adicionar ao layout. Em seguida, criamos o objeto `QVBoxLayout`, definindo ` window ` como pai ao passá-lo no construtor; depois, adicionamos os widgets ao layout. ` window ` será o pai dos widgets adicionados ao layout.
Se você não passar um pai window para o construtor, poderá, posteriormente, usar QWidget::setLayout() para instalar o objeto QVBoxLayout n window. Nesse momento, os widgets no layout terão seu pai alterado para window.

Consulte também QHBoxLayout, QGridLayout, QStackedLayout, Gerenciamento de Layout e Exemplo de Layouts Básicos.
Documentação das funções-membro
QVBoxLayout::QVBoxLayout()
Cria uma nova caixa vertical. É necessário adicioná-la a outro layout.
[explicit] QVBoxLayout::QVBoxLayout(QWidget *parent)
Cria uma nova caixa vertical de nível superior cujo pai é parent.
O layout é definido diretamente como o layout de nível superior para ` parent`. Só pode haver um layout de nível superior para um widget. Ele é retornado pela função ` QWidget::layout()`.
Veja também ` QWidget::setLayout()`.
[virtual noexcept] QVBoxLayout::~QVBoxLayout()
Destrói o layout desta caixa.
Os widgets do layout não são destruídos.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.