このページでは

StackLayout QML Type

StackLayoutクラスは、一度に1つのアイテムしか表示されないアイテムのスタックを提供します。詳細...

Import Statement: import QtQuick.Layouts
Inherits:

Item

プロパティ

付属物件

  • index : int (since QtQuick.Layouts 1.15)
  • isCurrentItem : bool (since QtQuick.Layouts 1.15)
  • layout : StackLayout (since QtQuick.Layouts 1.15)

詳細説明

この型をより効率的に使うためには、Qt Quick Layouts モジュールの一般的なメカニズムを理解しておくことをお勧めする。詳しくはQt Quick Layouts 概要を参照。

現在の可視アイテムは、currentIndex プロパティを設定することで変更できる。インデックスはStackLayoutの子の順番に対応します。

他のほとんどのレイアウトとは対照的に、子アイテムのLayout.fillWidthLayout.fillHeight プロパティのデフォルトはtrue です。その結果、子アイテムは、Layout.maximumWidth またはLayout.maximumHeight がそれを妨げない限り、StackLayout のサイズに合わせてデフォルトで充填されます。

アイテムをレイアウトに追加するには、アイテムをレイアウトに再ペアレントします。同様に、アイテムの削除は、アイテムをレイアウトから再arentすることによって行われます。これらの操作はどちらもレイアウトの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のアイテムは、これらのattachedプロパティをサポートしています:

attachedプロパティの詳細については、こちらをご覧ください。

ColumnLayout,GridLayout,RowLayout,StackView,Qt Quick Layouts Overviewも参照してください

プロパティのドキュメント

count : int [read-only]

このプロパティは、レイアウトに属するアイテムの数を保持します。

レイアウトの候補となるのは、StackLayout の子であるアイテムのみです。

currentIndex : int

このプロパティは、StackLayout で現在表示されている子アイテムのインデックスを保持します。デフォルトでは、空のレイアウトの場合は-1 となり、そうでない場合は0 (最初のアイテムを参照) となります。

6.5以降、現在のインデックス以下のインデックスで新しいItemを挿入/削除すると、現在のインデックスが増加/減少しますが、現在のItemは保持されます。

付属プロパティ文書

StackLayout.index : int [read-only, since QtQuick.Layouts 1.15]

この付属プロパティは、StackLayout 内の各子アイテムのインデックスを保持します。

このプロパティは QtQuick.Layouts 1.15 で導入されました。

isCurrentItem およびlayoutも参照してください

StackLayout.isCurrentItem : bool [read-only, since QtQuick.Layouts 1.15]

この子がStackLayout の現在のアイテムである場合、このアタッチされたプロパティはtrue になります。

このプロパティは、QtQuick.Layouts 1.15 で導入されました。

index およびlayoutも参照してください

StackLayout.layout : StackLayout [read-only, since QtQuick.Layouts 1.15]

この付属プロパティは、この子アイテムを管理するStackLayout を保持します。

このプロパティは QtQuick.Layouts 1.15 で導入されました。

indexisCurrentItemも参照してください

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