DelegateChooser QML Type
ビューがモデル内の異なる種類のアイテムに対して異なるデリゲートを使用できるようにします。詳細...
Import Statement: | import Qt.labs.qmlmodels |
プロパティ
詳細説明
DelegateChooser は、ビューで Component が必要とされ、デリゲートとして使用されるシナリオのための特別なComponent タイプです。DelegateChooser は、DelegateChoiceのセットをカプセル化します。 これらの選択肢は、モデル内の各アイテムに対してインスタンス化されるデリゲートを決定するために使用されます。選択肢の選択は、モデル項目がrole に持つ値に基づいて、またインデックスに基づいて実行されます。
DelegateChooserは、ビューが互いに大きく異なるデリゲートのセットを表示する必要がある場合に、一般的に使用されます。例えば、典型的な電話設定ビューには、トグルスイッチ、スライダー、ラジオボタン、および各設定のタイプに基づくその他のビジュアライゼーションが含まれるかもしれません。この場合、DelegateChooserは、各設定に異なるタイプのデリゲートを関連付ける簡単な方法を提供することができます:
import QtQuick import QtQuick.Controls import Qt.labs.qmlmodels ListView { width: 200; height: 400 ListModel { id: listModel ListElement { type: "info"; ... } ListElement { type: "switch"; ... } ListElement { type: "swipe"; ... } ListElement { type: "switch"; ... } } DelegateChooser { id: chooser role: "type" DelegateChoice { roleValue: "info"; ItemDelegate { ... } } DelegateChoice { roleValue: "switch"; SwitchDelegate { ... } } DelegateChoice { roleValue: "swipe"; SwipeDelegate { ... } } } model: listModel delegate: chooser }
注: このタイプは、TableView およびDelegateModel ベースのビューでのみ透過的に動作することを意図しています。内部的にDelegateModel に基づいていないビュー(ユーザー定義ビューを含む)は、このタイプのコンポーネントを明示的にサポートして、説明どおりに機能させる必要があります。
DelegateChoiceも参照してください 。
プロパティのドキュメント
choices : list<DelegateChoice> |
Chooser の DelegateChoices のリスト。
このリストは順序付きリストとして扱われ、最初にマッチしたDelegateChoice がビューとして使用されます。
choices
プロパティはDelegateChooser のデフォルトプロパティであり、したがって、すべての子項目は自動的にこのプロパティに割り当てられるため、通常、参照する必要はありません。
role : string |
このプロパティは、指定されたモデルアイテムのデリゲートを決定するために使用されるロールまたはプロパティ名を保持します。
注: ListModel を含むQAbstractItemModel ベースのモデルの場合、DelegateChooser は、モデルが役割が変更されたことを通知すると、その選択を再評価します。その他のタイプのモデルでは、この選択は、与えられたモデルインデックスの項目が作成されるときに一度だけ行われます。
DelegateChoiceも参照してください 。
© 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.