StackLayout QML Type
StackLayout クラスは、一度に 1 つのアイテムのみが表示されるアイテムのスタックを提供します。詳細...
| Import Statement: | import QtQuick.Layouts |
| Inherits: |
プロパティ
- count : int
- currentIndex : int
関連するプロパティ
- index : int
(since QtQuick.Layouts 1.15) - isCurrentItem : bool
(since QtQuick.Layouts 1.15) - layout : StackLayout
(since QtQuick.Layouts 1.15)
詳細な説明
このタイプをより効率的に使用するためには、Qt Quick のレイアウトモジュールの一般的な仕組みを理解しておくことをお勧めします。詳細については、「Qt Quick のレイアウトの概要」を参照してください。
currentIndex プロパティを設定することで、現在表示されている項目を変更できます。このインデックスは、StackLayout の子要素の順序に対応しています。
他のほとんどのレイアウトとは対照的に、子アイテムの `Layout.fillWidth ` および `Layout.fillHeight ` プロパティのデフォルト値は `true` です。その結果、子アイテムの `Layout.maximumWidth ` または `Layout.maximumHeight ` によって妨げられない限り、子アイテムはデフォルトで StackLayout のサイズに合わせて埋められます。
アイテムは、そのアイテムの親をレイアウトに変更することでレイアウトに追加されます。同様に、削除も、アイテムの親をレイアウトから変更することで行われます。これらの操作はいずれも、レイアウトのcount プロパティに影響を与えます。
次のコードは、「plum」という名前の長方形のみが表示される StackLayout を作成します。
StackLayout {
id: layout
anchors.fill: parent
currentIndex: 1
Rectangle {
color: 'teal'
implicitWidth: 200
implicitHeight: 200
}
Rectangle {
color: 'plum'
implicitWidth: 300
implicitHeight: 200
}
}StackLayout内のアイテムは、以下のアタッチドプロパティをサポートしています:
- Layout.minimumWidth
- Layout.minimumHeight
- Layout.preferredWidth
- Layout.preferredHeight
- Layout.maximumWidth
- Layout.maximumHeight
- Layout.fillWidth
- Layout.fillHeight
アタッチドプロパティの詳細については、こちらをご覧ください。
関連項目: ColumnLayout 、GridLayout 、RowLayout 、StackView 、およびQt Quick のレイアウト概要。
プロパティのドキュメント
count : int [read-only]
このプロパティには、そのレイアウトに属するアイテムの数が格納されます。
StackLayout の子要素であるアイテムのみが、レイアウトの対象となります。
currentIndex : int
このプロパティは、StackLayout で現在表示されている子項目のインデックスを保持します。デフォルトでは、レイアウトが空の場合は-1 となり、それ以外の場合は0 (最初の項目を指します)となります。
バージョン 6.5 以降、現在のインデックス以下に新しいアイテムを挿入または削除すると、現在のインデックスはインクリメントまたはデクリメントされますが、現在のアイテムは保持されます。
添付のプロパティのドキュメント
StackLayout.index : int [read-only attached, since QtQuick.Layouts 1.15]
この添付プロパティは、StackLayout 内の各子項目のインデックスを保持します。
このプロパティは、QtQuick.Layouts 1.15 で導入されました。
「 isCurrentItem 」および「layout 」も参照してください 。
StackLayout.isCurrentItem : bool [read-only attached, since QtQuick.Layouts 1.15]
この子要素がStackLayout の現在の項目である場合、この添付プロパティはtrue となります。
このプロパティは、QtQuick.Layouts 1.15 で導入されました。
「 index 」および「layout 」も参照してください 。
StackLayout.layout : StackLayout [read-only attached, since QtQuick.Layouts 1.15]
この添付プロパティには、この子アイテムを管理するStackLayout が格納されています。
このプロパティは、QtQuick.Layouts 1.15 で導入されました。
「 index 」および「isCurrentItem 」も参照してください 。
© 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.