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 レイアウトの概要を参照してください。

現在の表示項目は、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 レイアウトの概要も参照してください

プロパティの説明

count : int [read-only]

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

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


currentIndex : int

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

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


付属プロパティの説明

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

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

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

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


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

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

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

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


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

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

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

indexisCurrentItem参照して ください。


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