QVBoxLayout Class
La clase QVBoxLayout alinea los widgets verticalmente. Más...
| Cabecera: | #include <QVBoxLayout> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets)target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Hereda: | QBoxLayout |
Funciones Públicas
| QVBoxLayout() | |
| QVBoxLayout(QWidget *parent) | |
| virtual | ~QVBoxLayout() |
Descripción Detallada
Esta clase se utiliza para construir objetos de diseño de caja vertical. Véase QBoxLayout para más detalles.
El uso más sencillo de esta clase es el siguiente:
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();
Primero, creamos los widgets que queremos añadir al layout. Después, creamos el objeto QVBoxLayout, estableciendo window como padre pasándolo en el constructor; a continuación añadimos los widgets al layout. window será el padre de los widgets que se añadan al layout.
Si no pasas un padre window al constructor, puedes usar más tarde QWidget::setLayout() para instalar el objeto QVBoxLayout en window. En ese momento, los widgets del layout son reparentados para tener window como padre.

Ver también QHBoxLayout, QGridLayout, QStackedLayout, Gestión de Layouts, y Ejemplo de Layouts Básicos.
Documentación de las funciones miembro
QVBoxLayout::QVBoxLayout()
Construye una nueva caja vertical. Debe añadirla a otro diseño.
[explicit] QVBoxLayout::QVBoxLayout(QWidget *parent)
Construye una nueva caja vertical de nivel superior con el padre parent.
El diseño se establece directamente como el diseño de nivel superior para parent. Sólo puede haber un diseño de nivel superior para un widget. Es devuelto por QWidget::layout().
Véase también QWidget::setLayout().
[virtual noexcept] QVBoxLayout::~QVBoxLayout()
Destruye este diseño de caja.
Los widgets del diseño no se destruyen.
© 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.