ItemDelegate QML Type
基本项目委托,可用于各种视图和控件。更多
| Import Statement: | import QtQuick.Controls |
| Inherits: | |
| Inherited By: | CheckDelegate, HorizontalHeaderViewDelegate, RadioDelegate, SwipeDelegate, SwitchDelegate, TableViewDelegate, TreeViewDelegate, and VerticalHeaderViewDelegate |
属性
- highlighted : bool
详细说明
ItemDelegate 展示了一个标准视图项目。它可在各种视图和控件(如ListView 和ComboBox )中用作委托。
ItemDelegate 从AbstractButton 继承其 API。例如,您可以使用AbstractButton API 设置text 、显示图标并对clicks 做出反应。
ListView { id: listView width: 160 height: 240 model: Qt.fontFamilies() delegate: ItemDelegate { text: modelData width: listView.width onClicked: console.log("clicked:", modelData) required property string modelData } ScrollIndicator.vertical: ScrollIndicator { } }
另请参阅 自定义 ItemDelegate和委托控件。
属性文档
highlighted : bool
该属性显示委托是否高亮显示。
委托可以高亮显示,以引起用户对它的注意。它对键盘交互没有影响。例如,您可以使用以下代码高亮显示ListView 中的当前项目:
ListView { id: listView model: 10 delegate: ItemDelegate { text: index highlighted: ListView.isCurrentItem required property int index onClicked: listView.currentIndex = index } }
默认值为false 。
© 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.