QHBoxLayout Class
QHBoxLayout クラスは、ウィジェットを水平方向に並べるものです。詳細...
| ヘッダー: | #include <QHBoxLayout> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QBoxLayout |
パブリック関数
| QHBoxLayout() | |
| QHBoxLayout(QWidget *parent) | |
| virtual | ~QHBoxLayout() |
詳細な説明
このクラスは、水平方向のボックスレイアウトオブジェクトを構築するために使用されます。詳細については、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");
QHBoxLayout *layout = new QHBoxLayout(window);
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->show();まず、レイアウトに追加したいウィジェットを作成します。次に、コンストラクタにwindow を引数として渡し、親として設定してQHBoxLayoutオブジェクトを作成します。その後、ウィジェットをレイアウトに追加します。window は、レイアウトに追加されたウィジェットの親となります。
コンストラクタに親のwindow を渡さなかった場合でも、後でQWidget::setLayout() を使用して、QHBoxLayoutオブジェクトをwindow にインストールすることができます。その時点で、レイアウト内のウィジェットの親はwindow に変更されます。

「 QVBoxLayout 」、「QGridLayout 」、「QStackedLayout 」、「レイアウト管理」、および「基本的なレイアウトの例」も参照してください 。
メンバ関数のドキュメント
QHBoxLayout::QHBoxLayout()
新しい横長のボックスを作成します。これを別のレイアウトに追加する必要があります。
[explicit] QHBoxLayout::QHBoxLayout(QWidget *parent)
親要素が `parent` である新しい最上位の水平ボックスを作成します。
レイアウトは、parent のトップレベルレイアウトとして直接設定されます。ウィジェットにはトップレベルレイアウトが1つしか存在できません。これはQWidget::layout() によって返されます。
QWidget::setLayout()も参照してください 。
[virtual noexcept] QHBoxLayout::~QHBoxLayout()
このボックスレイアウトを破棄します。
レイアウト内のウィジェットは破棄されません。
© 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.