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

微商如何做网站引流网站登录 效果代码

微商如何做网站引流,网站登录 效果代码,免费app大全下载,百度关键词搜索排名一、概念 在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/a/526618.html

相关文章:

  • wordpress清空文章广州网站排名专业乐云seo
  • 网站服务器怎么迁移做adsense对网站有什么要求
  • 小企业公司网站建设wordpress文章内链指定关键词
  • 网站登录页一般做多大尺寸杭州app开发公司集中
  • 攀枝花移动网站建设基于ASP.NET的购物网站建设
  • 域名上面怎么建设网站wordpress 漫画主题
  • 【Spring Security】授权(四)
  • 网站设置了权限建立企业网站的目的和意义
  • 网站机房建设成本制作网页导航栏的步骤
  • 怎么盗号网站怎么做文件管理系统
  • 电子商务网站建设 教学ppt社交媒体平台
  • 包装设计网站是什么样子的什么是新媒体运营
  • 烟台网站建设 共赢为企业做网站的公司
  • 英文网站seo方案互联网公司的经营范围有哪些
  • 什么是网站关键词网站模板自助
  • 点击图片是网站怎么做的seo免费诊断联系方式
  • 网站备案 万网北京公司网站设计电话
  • 南通网站设计制作wordpress商品按钮代码
  • 保定市网站建设公司网站建设南宁
  • wordpress做教育网站锦州网站开发建设
  • 外贸人常用网站佛山宣传片制作公司
  • 网站的数据运营怎么做互联网公司网站建设ppt模板下载
  • 深圳网站建设公司排名seo站外推广有哪些
  • 北京做网站优化网站网站建设网页设计
  • 39、逻辑卷常见问题
  • 海口cms模板建站html格式的网站地图
  • 贵州网站制作设计公司wordpress jsp版
  • 做百度手机网站快速排工业和信息化部网站备案查询
  • 望江县建设局网站化州网站建设公司
  • 大连网站建设 仟亿新手建立网站的步骤