Package QML Type
명명된 항목의 컬렉션을 지정합니다. 자세히...
Import Statement: | import QtQml.Models |
첨부된 속성
- name : string
자세한 설명
패키지 유형은 DelegateModel 와 함께 사용되어 공유 컨텍스트를 가진 델리게이트를 여러 보기에 제공할 수 있도록 합니다.
패키지 내의 모든 항목은 Package.name 첨부 속성을 통해 이름을 지정할 수 있습니다.
아래 예에서는 목록과 그리드라는 두 개의 명명된 항목이 포함된 패키지를 만듭니다. 패키지의 세 번째 항목( Rectangle)은 해당 항목이 표시되어야 하는 델리게이트에 부모가 됩니다. 이렇게 하면 항목이 보기 간에 이동할 수 있습니다.
Package { Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } Rectangle { id: wrapper width: parent.width; height: 25 color: 'lightsteelblue' Text { text: display; anchors.centerIn: parent } state: root.upTo > index ? 'inGrid' : 'inList' states: [ State { name: 'inList' ParentChange { target: wrapper; parent: listDelegate } }, State { name: 'inGrid' ParentChange { target: wrapper; parent: gridDelegate x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height } } ] transitions: [ Transition { ParentAnimation { NumberAnimation { properties: 'x,y,width,height'; duration: 300 } } } ] } }
이러한 명명된 항목은 특수 DelegateModel::parts 속성을 참조하여 선택한 델리게이트를 제공하는 모델을 선택하는 두 보기에서 델리게이트로 사용됩니다.
DelegateModel { id: visualModel delegate: Delegate {} model: myModel } ListView { id: lv height: parent.height/2 width: parent.width model: visualModel.parts.list } GridView { y: parent.height/2 height: parent.height/2 width: parent.width cellWidth: width / 2 cellHeight: 50 model: visualModel.parts.grid }
참고: 패키지는 버전 2.14부터 QtQml.Models의 일부이며, 버전 2.0부터는 QtQuick 의 일부입니다. QtQuick 을 통한 패키지 임포트는 Qt 5.14부터 더 이상 사용되지 않습니다.
첨부된 속성 문서
Package.name : string |
이 첨부 프로퍼티는 패키지 내 항목의 이름을 저장합니다.
© 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.