当前位置: 首页 > wzjs >正文

网站一级域名申请电商怎么做新手入门

网站一级域名申请,电商怎么做新手入门,360的网站怎么做,品牌网站制作报价表一、概念 在QML中,Delegate是一种非常重要的组件,特别是在使用ListView、GridView、PathView等视图组件时。Delegate用于定义每个列表或网格中的项目是如何展示的。通过自定义Delegate,你可以控制每个项目的外观和行为。 Delegate通常是一个…

、概念

QML中,Delegate是一种非常重要的组件,特别是在使用ListViewGridViewPathView等视图组件时。Delegate用于定义每个列表或网格中的项目是如何展示的。通过自定义Delegate,你可以控制每个项目的外观和行为。

Delegate通常是一个自定义的ItemComponent,它定义了如何在列表或网格中显示每个项目。例如,你可以在Delegate中定义文本标签、图片、按钮等。

、常用委托控件

常用委托控件:ItemDelegate、CheckDelegate、RadioDelegate、SwitchDelegate和SwipeDelegate。

1.‌ItemDelegate

属性/信号/方法类型说明示例
‌highlighted‌bool当前项高亮状态,常用于列表选中项highlighted: ListView.isCurrentItem
‌text‌string显示的主文本内容text: model.name
‌icon‌var左侧图标资源(QtQuick.Icon类型)icon.source: "icon.png"
‌spacing‌real图标与文本间距(像素)spacing: 10
‌padding‌real内容区域内边距padding: 12
‌onClicked‌signal点击时触发onClicked: console.log(index)
‌background‌Component自定义背景组件background: Rectangle{color:"red"}

代码示例:

    //ItemDelegateListView {id: listViewItemx: 0; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: ItemDelegate {text: modelDatawidth: listViewItem.widthicon.source:"qrc:/image/user.png"icon.color: "transparent"//icon.name: "edit-cut"display: AbstractButton.TextBesideIconhighlighted: ListView.isCurrentItemonClicked: {listViewItem.currentIndex = index;console.log("clicked:", modelData)}}}

运行结果:

2.CheckDelegate

属性/信号/方法类型说明示例
‌checkState‌enum三态状态(Checked/Unchecked/PartiallyChecked)checkState: Qt.Checked
‌tristate‌bool是否启用三态模式tristate: true
‌checked‌bool当前选中状态checked: model.selected
‌onToggled‌signal状态变化时触发onToggled: model.checked=checked
‌indicator‌Component自定义复选框样式indicator: Rectangle{...}
‌nextCheckState‌method控制点击时的状态切换逻辑function nextCheckState(){...}

代码示例:

    //CheckDelegateproperty var selectedItems: []ListView {id: listViewCheckx: 320; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: CheckDelegate {text: modelDatawidth: listViewCheck.widthonCheckedChanged: {if (checked) {selectedItems.push(modelData)} else {selectedItems = selectedItems.filter(item => item !== modelData)}}}}Button {text: "Selected Items"anchors.bottom: listViewCheck.bottomanchors.horizontalCenter: listViewCheck.horizontalCenteronClicked: {console.log("Selected items:", selectedItems)}}

运行结果:

3.RadioDelegate

属性/信号/方法类型说明示例
‌autoExclusive‌bool同组单选按钮自动互斥autoExclusive: true
‌checked‌bool当前选中状态checked: model.isSelected
‌onClicked‌signal点击时触发onClicked: group.update(index)
‌indicator‌Component自定义单选按钮样式indicator: Circle{...}
‌text‌string显示文本标签text: model.option

代码示例:

//RadioDelegateproperty string selectedItem: "Item 1"  // 默认值需与初始checked项匹配ListView {id: listViewRadiox: 640; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: RadioDelegate {text: modelDatawidth: listViewRadio.widthchecked: selectedItem === modelDataonCheckedChanged: {if (checked) {selectedItem = modelData}}}}Button {text: "Selected Item"anchors.bottom: listViewRadio.bottomanchors.horizontalCenter: listViewRadio.horizontalCenteronClicked: console.log("Selected Item:", selectedItem)}

运行结果:

4.SwitchDelegate

属性/信号/方法类型说明示例
‌position‌real滑块位置(0.0-1.0)position: 0.7
‌checked‌bool当前开关状态checked: model.active
‌onToggled‌signal状态变化时触发onToggled: settings.save()
‌indicator‌Component自定义滑块组件indicator: Slider{...}
‌visualPosition‌real动画过渡中的可视位置visualPosition: 0.5

代码示例:

    //SwitchDelegateListView {id: listViewSwitchx: 0; y: 320width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: SwitchDelegate {text: modelDatawidth: listViewSwitch.width}}

运行结果:

 5.SwipeDelegate

属性/信号/方法类型说明示例
‌swipe.left‌Component左滑时显示的组件swipe.left: Rectangle{...}
‌swipe.right‌Component右滑时显示的组件swipe.right: Image{...}
onCompletedsignal完成滑动操作时触发onCompleted: list.remove(index)
‌swipe.position‌real当前滑动进度(-1.0到1.0)swipe.position: 0.3
‌behind‌Component滑动后显示的背景组件behind: DeleteButton{...}

代码示例:

//SwipeDelegateListModel {id: listModelListElement { name: "Item 1" }ListElement { name: "Item 2" }ListElement { name: "Item 3" }ListElement { name: "Item 4" }ListElement { name: "Item 5" }}// 列表视图ListView {x: 320; y: 320width: 300height: 300model: listModeldelegate: SwipeDelegate {width: parent.widthheight: 60text: nameswipe.left: Rectangle {width: parent.widthheight: parent.heightcolor: "#ff4444"Label {anchors.centerIn: parenttext: "删除"color: "white"font.bold: true}// 点击删除按钮时移除项目MouseArea {anchors.fill: parentonClicked: listModel.remove(index)}}// 滑动完成时自动恢复位置//swipe.onCompleted: swipe.close()}// 滚动条ScrollIndicator.vertical: ScrollIndicator {}}

运行结果:

关键特性说明:

  1. 所有Delegate均继承自AbstractButton,支持点击/按压等基础交互
  2. 自定义样式推荐通过覆盖backgroundcontentItem实现
  3. SwipeDelegate需配合ListView使用才能获得完整手势支持

完整代码

代码:

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.6Window {visible: truewidth: 960height: 640title: qsTr("Hello World")//ItemDelegateListView {id: listViewItemx: 0; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: ItemDelegate {text: modelDatawidth: listViewItem.widthicon.source:"qrc:/image/user.png"icon.color: "transparent"//icon.name: "edit-cut"display: AbstractButton.TextBesideIconhighlighted: ListView.isCurrentItemonClicked: {listViewItem.currentIndex = index;console.log("clicked:", modelData)}}}//CheckDelegateproperty var selectedItems: []ListView {id: listViewCheckx: 320; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: CheckDelegate {text: modelDatawidth: listViewCheck.widthonCheckedChanged: {if (checked) {selectedItems.push(modelData)} else {selectedItems = selectedItems.filter(item => item !== modelData)}}}}Button {text: "Selected Items"anchors.bottom: listViewCheck.bottomanchors.horizontalCenter: listViewCheck.horizontalCenteronClicked: {console.log("Selected items:", selectedItems)}}//RadioDelegateproperty string selectedItem: "Item 1"  // 默认值需与初始checked项匹配ListView {id: listViewRadiox: 640; y: 0width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: RadioDelegate {text: modelDatawidth: listViewRadio.widthchecked: selectedItem === modelDataonCheckedChanged: {if (checked) {selectedItem = modelData}}}}Button {text: "Selected Item"anchors.bottom: listViewRadio.bottomanchors.horizontalCenter: listViewRadio.horizontalCenteronClicked: console.log("Selected Item:", selectedItem)}//SwitchDelegateListView {id: listViewSwitchx: 0; y: 320width: 300height: 300model: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]delegate: SwitchDelegate {text: modelDatawidth: listViewSwitch.width}}//SwipeDelegateListModel {id: listModelListElement { name: "Item 1" }ListElement { name: "Item 2" }ListElement { name: "Item 3" }ListElement { name: "Item 4" }ListElement { name: "Item 5" }}// 列表视图ListView {x: 320; y: 320width: 300height: 300model: listModeldelegate: SwipeDelegate {width: parent.widthheight: 60text: nameswipe.left: Rectangle {width: parent.widthheight: parent.heightcolor: "#ff4444"Label {anchors.centerIn: parenttext: "删除"color: "white"font.bold: true}// 点击删除按钮时移除项目MouseArea {anchors.fill: parentonClicked: listModel.remove(index)}}// 滑动完成时自动恢复位置//swipe.onCompleted: swipe.close()}// 滚动条ScrollIndicator.vertical: ScrollIndicator {}}
}

运行结果:

http://www.dtcms.com/wzjs/345502.html

相关文章:

  • 卡盟网站模板外链生成工具
  • wordpress音乐代码昆明网站seo公司
  • 做宣传单用什么网站找图片素材如何建立和设计公司网站
  • 盗用网站模板微营销系统
  • 芙蓉区网站建设公司路由器优化大师
  • 用织梦做的网站怎样看网站友链外链
  • 自己做的网站发布详细步骤网络推广培训去哪里好
  • 免费ui设计网站今天最新军事新闻视频
  • wordpress禁用php报错武汉seo 网络推广
  • 代刷网站只做软件武汉大学人民医院精神科
  • 建设网站书百度网盘搜索免费资源
  • php网站攻击百家号优化
  • 番禺网站建设设计竞价推广
  • 灯具设计网站推荐优化seo哪家好
  • 中国廉政建设网网站网络关键词优化方法
  • dedecms 古典棕色大气风格中药医药企业网站模板源码网络推广整合平台
  • wordpress访问仪表盘宝鸡网站seo
  • 百度官方网站首页aso是什么意思
  • 自己编写代码建设微网站营销系统
  • 专业做网站哪家好如何推广引流
  • 外贸批发网站互联网电商平台有哪些
  • 用什么软件做网站最简单网络营销是什么意思
  • 凡科h5制作教程好搜网惠州seo
  • 想在百度上做网站seo软件代理
  • 济南网站建设找凌峰百度推广软件
  • 餐饮企业网站建设网站搜索引擎
  • 设计素材网站推荐pin阿里网站seo
  • 怎样做网站测评竞价代运营公司
  • 网站建设网络公司网站推广的技巧
  • wordpress不在新窗口打seo技术培训学校