SwipeView QML Type
横スワイプによるページ移動を可能にする。もっと見る...
Import Statement: | import QtQuick.Controls |
Inherits: |
プロパティ
- horizontal : bool
(since QtQuick.Controls 2.3 (Qt 5.10))
- interactive : bool
(since QtQuick.Controls 2.1 (Qt 5.8))
- orientation : enumeration
(since QtQuick.Controls 2.2 (Qt 5.9))
- vertical : bool
(since QtQuick.Controls 2.3 (Qt 5.10))
付属物件
- index : int
- isCurrentItem : bool
- isNextItem : bool
(since QtQuick.Controls 2.1 (Qt 5.8))
- isPreviousItem : bool
(since QtQuick.Controls 2.1 (Qt 5.8))
- view : SwipeView
詳細説明
SwipeViewはスワイプベースのナビゲーションモデルを提供します。
SwipeViewにはページが表示されます。一度に1つのページが表示されます。ユーザーは横にスワイプすることでページ間を移動できます。SwipeView自体は完全に非ビジュアルであることに注意してください。ユーザーに複数のページがあることを視覚的に示すために、PageIndicator と組み合わせることをお勧めします。
SwipeView { id: view currentIndex: 1 anchors.fill: parent Item { id: firstPage } Item { id: secondPage } Item { id: thirdPage } } PageIndicator { id: indicator count: view.count currentIndex: view.currentIndex anchors.bottom: view.bottom anchors.horizontalCenter: parent.horizontalCenter }
上に示したように、SwipeViewは通常、ビューの子としてインラインで定義された静的なページ・セットで構成されます。また、実行時に動的にadd 、insert 、move 、remove 。
SwipeViewがTabBar のような他のコンテナと対になっている場合、各コントロールのcurrentIndex プロパティ間で双方向バインディングを行う必要があります。バインディングを壊さずにこれを行うには、currentIndex
を直接設定することを避け、代わりにsetCurrentIndex() などを使用します。詳しくはManaging the Current Index を参照してください。
currentIndex
が変更されたときにアクションを実行するには、onCurrentIndexChanged
プロパティ変更シグナル・ハンドラを使用します:
onCurrentIndexChanged: { print("currentIndex changed to", currentIndex) // ... }
一般的に、SwipeViewに過剰な量のページを追加することはお勧めしません。しかし、ページの量が多くなったり、個々のページが比較的複雑になったりすると、ユーザーの手の届かないページをアンロードしてリソースを解放することが望ましい場合があります。次の例では、Loader 、最大3つのページを同時にインスタンス化する方法を紹介します。
SwipeView { Repeater { model: 6 Loader { active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem sourceComponent: Text { text: index Component.onCompleted: console.log("created:", index) Component.onDestruction: console.log("destroyed:", index) } } } }
注: SwipeViewは、ビューに追加されたアイテムのジオメトリ管理を引き継ぎます。アイテムにアンカーを使用することはサポートされておらず、width
またはheight
の割り当てはビューによって上書きされます。これはアイテムのルートにのみ適用されます。幅と高さを指定したり、子アイテムにアンカーを使用したりすると、期待通りに動作します。
TabBar 、PageIndicator 、 Qt Quick Controls の SwipeView、ナビゲーション・コントロール、コンテナ・コントロール、フォーカス管理の カスタマイズも参照してください 。
プロパティ ドキュメント
horizontal : bool |
このプロパティは、スワイプビューが水平かどうかを保持します。
このプロパティは、QtQuick.Controls 2.3(Qt 5.10)で導入されました。
orientationも参照してください 。
interactive : bool |
このプロパティは、ユーザーがSwipeView と対話できるかどうかを記述します。 ユーザーは、対話できないビューをスワイプすることはできません。
デフォルト値はtrue
です。
このプロパティは、QtQuick.Controls 2.1(Qt 5.8)で導入されました。
orientation : enumeration |
このプロパティは、方向を保持します。
可能な値:
定数 | 説明 |
---|---|
Qt.Horizontal | Horizontal (デフォルト) |
Qt.Vertical | 垂直 |
このプロパティは QtQuick.Controls 2.2 (Qt 5.9) で導入されました。
horizontal およびverticalも参照してください 。
vertical : bool |
このプロパティは、スワイプビューが垂直かどうかを保持します。
このプロパティは QtQuick.Controls 2.3 (Qt 5.10) で導入されました。
orientationも参照して ください。
Attached Property ドキュメント
SwipeView.index : int |
SwipeView.isCurrentItem : bool |
この子項目が現在の項目の場合、この Attached プロパティはtrue
になります。
このプロパティは、SwipeView の各子項目に添付されます。
SwipeView.isNextItem : bool |
この子が次の項目の場合、この付属プロパティはtrue
です。
このプロパティは、SwipeView の各子アイテムにアタッチされます。
このプロパティは QtQuick.Controls 2.1 (Qt 5.8) で導入されました。
SwipeView.isPreviousItem : bool |
この子が前の項目である場合、この attached プロパティはtrue
です。
SwipeView の各子アイテムにアタッチされます。
このプロパティは、QtQuick.Controls 2.1 (Qt 5.8)で導入されました。
SwipeView.view : SwipeView |
この attached プロパティは、この子項目を管理するビューを保持します。
このプロパティは、SwipeView の各子アイテムにアタッチされます。
© 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.