QHBoxLayout Class
La clase QHBoxLayout alinea los widgets horizontalmente. Más información...
| Encabezado: | #include <QHBoxLayout> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Heredan de: | QBoxLayout |
Funciones públicas
| QHBoxLayout() | |
| QHBoxLayout(QWidget *parent) | |
| virtual | ~QHBoxLayout() |
Descripción detallada
Esta clase se utiliza para construir objetos de diseño de cuadros horizontales. Consulte QBoxLayout para obtener más detalles.
El uso más sencillo de la 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");
QHBoxLayout *layout = new QHBoxLayout(window);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->show();En primer lugar, creamos los widgets que queremos añadir al diseño. A continuación, creamos el objeto QHBoxLayout, estableciendo window como padre al pasárselo en el constructor; después, añadimos los widgets al diseño. window será el padre de los widgets que se añadan al diseño.
Si no se pasa un padre « window » al constructor, se puede utilizar posteriormente « QWidget::setLayout()» para instalar el objeto «QHBoxLayout» en « window ». En ese momento, los widgets del diseño cambian de padre y pasan a tener « window » como padre.

Véase también QVBoxLayout, QGridLayout, QStackedLayout, «Gestión de diseños» y «Ejemplo de diseños básicos».
Documentación de las funciones de miembro
QHBoxLayout::QHBoxLayout()
Crea un nuevo cuadro horizontal. Debes añadirlo a otro diseño.
[explicit] QHBoxLayout::QHBoxLayout(QWidget *parent)
Crea un nuevo cuadro horizontal de nivel superior cuyo padre es parent.
El diseño se establece directamente como el diseño de nivel superior para parent. Solo puede haber un diseño de nivel superior para un widget. Se devuelve mediante QWidget::layout().
Véase también QWidget::setLayout().
[virtual noexcept] QHBoxLayout::~QHBoxLayout()
Elimina este diseño de cuadro.
Los widgets del diseño no se eliminan.
© 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.