Qml-CheckBox的使用

news/2024/10/23 5:42:26/

Qml-CheckBox的使用

CheckBox属性

  1. CheckBox的继承关系: CheckBox – AbstractButton – Control – Item; CheckBox的属性主要继承于AbstractButton。
  2. 属性checkState:勾选状态,值为:Qt.Unchecked、Qt.Checked、Qt.PartiallyChecked
  3. 属性nextCheckState:定义一个回调函数,当勾选状态发生变化时,调用,返回下个状态。
  4. 属性tristate:是否使能CheckBox为三态勾选框,默认CheckBox是二态即(Qt.Checked 和Qt.Unchecked)两种状态之间切换。注意,当tristate为true时,toggled()信号不会在发送。
  5. 注意:在使用CheckBox时,如果将checkable属性设置为false,勾选将不生效。

CheckBox的实例代码

import QtQuick
import QtQuick.ControlsItem {anchors.fill: parentRow{id:idRowanchors.top: parent.topanchors.left: parent.leftanchors.margins: 10spacing: 10CheckBox{id:idCheck1text:"check1"checkState: Qt.Uncheckedtristate:true                                           //checkbox 是三态 CheckBox,默认tristate 为false,当tristate为true时,toggled信号不在发送onClicked: {console.log("check1 clicked tristate = ");console.log("indicator width = ",indicator.width);  //checkBox的勾选框就是一个indicator对象(Item对象)}onToggled: {console.log("check1 toggled "/*,checked ? "checked " : "unchecked"*/);}}CheckBox{id:idCheck2//checkable: false                                              //checkable:设置为false,勾选不会生效text:"check2"checkState: Qt.CheckednextCheckState: function(){                                     //返回下一个勾选状态()if(checkState == Qt.Unchecked)return Qt.Checkedelsereturn Qt.Unchecked}onClicked: {console.log("check2 clicked tristate = ",tristate ? " true" : " false");}onToggled: {console.log("check2 toggled ",checked ? "checked " : "unchecked");}}}
}

http://www.ppmy.cn/news/1541244.html

相关文章

iOS弹出系统相册选择弹窗

直接上代码 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {UIImagePickerController *imagePickerController [[UIImagePickerController alloc] init];imagePickerController.delegate self; //设置代理imagePicke…

Greenhills学习总结

学习背景:近期参与xx项目过程中,遇到较多的关于代码集成编译的知识盲区,因此需要进行相关知识的学习和扫盲。 参考资料:GreenHills2017.7编译手册:本手册是GreenHills 2017.7.14版编译器的软件使用手册。该手册详细介绍了GreenHi…

Electron+Vue实现两种方式的截屏功能

本次介绍的截屏功能一共有两种分别是在electron环境中与非electron环境中 非electron环境 这个环境下会有一些限制: 1.只能截浏览器中的画面 2.如果里面有iframe或者base64的图片会加载不出来(这个会有解决办法) yarn add -D js-web-scree…

UE5遇到问题-UE5可正常打包出来但是运行不了

遇到问题: UE5可正常打包出来但是运行不了 解决办法: 首先先在本地运行跑一下工程; 发现是没有关闭插件的问题,点开插件关闭掉相应的插件重新打包就可以了。 参考视频:(新手向)虚幻5打包 打包后双击exe没反应怎么办…

【Unity】Unity中获取网络时间进行每日和每月刷新

直接上代码 using System; using System.Collections; using System.Collections.Generic; using UnityEngine;public class DateChecker : MonoBehaviour {private DateTime lastCheckedDate; //上次刷新日数据的日期private DateTime lastMonthUtc; //上次刷新月数据的日期T…

玫瑰花HTML源码

HTML源码 <pre id"tiresult" style"font-size: 9px; background-color: #000000; font-weight: bold; padding: 4px 5px; --fs: 9px;"><b style"color:#000000">0010000100000111101110110111100010000100000100001010111111100110…

Kafka原理剖析之「Purgatory(炼狱 | 时间轮)」

一、前言 本文介绍一下Kafka赫赫有名的组件Purgatory&#xff0c;相信做Kafka的朋友或多或少都对其有一定的了解&#xff0c;至少是听过它的名字。那它的作用是什么呢&#xff0c;用来解决什么问题呢&#xff1f;官网confluent早就有文章对其做了阐述 https://cwiki.apache.o…

django开发连接Mysql报错1045或08001问题处理方法

存在问题&#xff1a; django开发过程中&#xff0c;连接mysql数据库一直报错&#xff0c;如下&#xff1a; 或 网上搜索各种解决办法均无效&#xff08;类似加密方式、配置方式等&#xff09; 解决方案&#xff1a; 查看mysql版本&#xff0c;为8.0.26 django开发中&#x…