DelegateChooser QML Type
뷰에서 모델 내 항목의 유형에 따라 서로 다른 델리게이트를 사용할 수 있게 합니다. 더 보기...
| Import Statement: | import QtQml.Models |
| Since: | Qt 6.9 |
속성
상세 설명
DelegateChooser는 뷰에서 컴포넌트가 필요하며 이를 델리게이트로 사용하는 시나리오를 위해 고안된 특수한 Component 유형입니다. DelegateChooser는 일련의 선택 항목( DelegateChoice)을 캡슐화합니다. 이러한 선택 항목들은 모델의 각 항목에 대해 인스턴스화될 델리게이트를 결정하는 데 사용됩니다. 선택 항목의 선정은 모델 항목이 가진 ` role` 값과 인덱스를 기반으로 수행됩니다.
DelegateChooser는 뷰에서 서로 상당히 다른 일련의 델리게이트를 표시해야 할 때 흔히 사용됩니다. 예를 들어, 일반적인 휴대폰 설정 화면에는 각 설정의 유형에 따라 토글 스위치, 슬라이더, 라디오 버튼 및 기타 시각화 요소가 포함될 수 있습니다. 이 경우, DelegateChooser를 사용하면 각 설정에 서로 다른 유형의 델리게이트를 쉽게 연결할 수 있습니다:
import QtQml.Models
import QtQuick
import QtQuick.Controls
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> [default]
선택기(chooser)에 대한 DelegateChoices 목록입니다.
이 목록은 순서가 지정된 목록으로 처리되며, 뷰에서는 일치하는 첫 번째 DelegateChoice 가 사용됩니다.
choices 속성은 DelegateChooser 의 기본 속성이므로, 일반적으로 이 속성을 참조할 필요는 없으며, 따라서 모든 자식 항목은 자동으로 이 속성에 할당됩니다.
role : string
이 속성은 주어진 모델 항목에 대한 대리자를 결정하는 데 사용되는 역할 또는 속성 이름을 포함합니다.
참고: ListModel 을 포함한 QAbstractItemModel 기반 모델의경우 , 모델에서 역할이 변경되었다는 신호를 보내면 DelegateChooser 가 해당 선택 사항을 재평가합니다. 그 외의 모든 유형의 모델에서는, 특정 모델 인덱스에 해당하는 항목이 생성될 때만 이 선택이 한 번 수행됩니다.
DelegateChoice도 참조하십시오 .
© 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.