このページでは

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();

まず、レイアウトに追加したいウィジェットを作成します。次に、QVBoxLayout オブジェクトを作成し、コンストラクタにwindow を渡して親として設定します。その後、ウィジェットをレイアウトに追加します。window は、レイアウトに追加されたウィジェットの親となります。

コンストラクタに親となるwindow を渡さなかった場合でも、後でQWidget::setLayout() を使用して、QVBoxLayoutオブジェクトをwindow にインストールすることができます。その時点で、レイアウト内のウィジェットの親はwindow に変更されます。

5つの子ウィジェットを含む水平配置のボックスレイアウト

「 QHBoxLayout 」、「QGridLayout 」、「QStackedLayout 」、「レイアウト管理」、および「基本レイアウトの例」も参照してください 。

メンバ関数のドキュメント

QVBoxLayout::QVBoxLayout()

新しい縦長のボックスを作成します。これを別のレイアウトに追加する必要があります。

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

親要素が `parent` である新しいトップレベルの垂直ボックスを作成します。

レイアウトは、parent のトップレベルレイアウトとして直接設定されます。ウィジェットにはトップレベルレイアウトが1つしか存在できません。これは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.