이 페이지에서

QVBoxLayout Class

QVBoxLayout 클래스는 위젯을 수직으로 정렬합니다. 더 보기...

헤더: #include <QVBoxLayout>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
상속: QBoxLayout

공개 함수

QVBoxLayout()
QVBoxLayout(QWidget *parent)
virtual ~QVBoxLayout()

상세 설명

이 클래스는 수직 박스 레이아웃 객체를 생성하는 데 사용됩니다. 자세한 내용은 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");

QVBoxLayout *layout = new QVBoxLayout(window);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);

window->show();

먼저, 레이아웃에 추가할 위젯을 생성합니다. 그런 다음, 생성자에 window 를 부모로 전달하여 QVBoxLayout 객체를 생성하고, 이어서 위젯을 레이아웃에 추가합니다. window 는 레이아웃에 추가된 위젯들의 부모가 됩니다.

생성자에 부모 window 를 전달하지 않은 경우, 나중에 QWidget::setLayout()를 사용하여 QVBoxLayout 객체를 window 에 설치할 수 있습니다. 이때 레이아웃 내의 위젯들은 window 를 부모로 갖도록 부모가 재설정됩니다.

5개의 자식 위젯이 포함된 수평 박스 레이아웃

QHBoxLayout, QGridLayout, QStackedLayout, 레이아웃 관리 및 기본 레이아웃 예제도참조하십시오 .

멤버 함수 문서

QVBoxLayout::QVBoxLayout()

새로운 세로 상자를 생성합니다. 이 상자는 다른 레이아웃에 추가해야 합니다.

[explicit] QVBoxLayout::QVBoxLayout(QWidget *parent)

parent 를 부모로 하는 새로운 최상위 수직 상자를 생성합니다.

레이아웃은 ` parent`의 최상위 레이아웃으로 직접 설정됩니다. 위젯당 최상위 레이아웃은 하나만 존재할 수 있습니다. 이 레이아웃은 ` QWidget::layout()` 함수에 의해 반환됩니다.

QWidget::setLayout()도 참조하십시오 .

[virtual noexcept] QVBoxLayout::~QVBoxLayout()

이 박스 레이아웃을 제거합니다.

레이아웃의 위젯은 제거되지 않습니다.

© 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.