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

【Qt之Quick模块】5. QML基本类型及示例用法

QML格式

QML基本类型

在 QML 中,有以下基本类型:

  1. int:整数类型。
Rectangle {function myFunction() {// 输出 debug 信息console.log("1+1 =" + (1+1));}Component.onCompleted: {myFunction();}
}

结果:
在这里插入图片描述
2. real:浮点类型。
3. double:双精度浮点类型。
4. string:字符串类型。

Rectangle {function myFunction() {// 输出 debug 信息console.log("helloworld");}Component.onCompleted: {myFunction();}
}

结果:
在这里插入图片描述
5. bool:布尔类型。
6. color:颜色类型,用于表示颜色的RGBA值。
7. var:通用类型,可以表示任意类型的数据。

    Item {property var myVar: "Hello World"Component.onCompleted: {console.log(myVar) // 输出 "Hello World" 到控制台}}

结果:
在这里插入图片描述
8. date:日期类型。

Rectangle {Item {property var currentDate: new Date()Component.onCompleted: {console.log(currentDate.toString()) // 输出当前日期和时间到控制台}}
}

结果:
在这里插入图片描述
9. point:点类型,用于表示二维空间中的点。

Item {width: 200height: 200property var point: Qt.point(50, 100)Component.onCompleted: {console.log(point.x, point.y) // 输出点对象的坐标值到控制台}
}

结果:
在这里插入图片描述
10. size:尺寸类型,用于表示宽度和高度。

Item {width: 200height: 200property size var_size: Qt.size(0, 2)Component.onCompleted: {console.log(var_size) // 输出点对象的坐标值到控制台}
}

结果:
在这里插入图片描述
11. rect:矩形类型,用于表示矩形区域的左上角坐标和宽高。

Item {width: 200height: 200property rect var_rect: Qt.rect(0, 0, 1, 2)Component.onCompleted: {console.log(var_rect) // 输出点对象的坐标值到控制台}
}

结果:
在这里插入图片描述

http://www.lryc.cn/news/265218.html

相关文章:

  • MySQL运维实战(1.2)安装部署:使用二进制安装部署
  • ChatGPT一周年:开源语言大模型的冲击
  • C++ Qt开发:Charts绘图组件概述
  • 基于Java+SpringBoot实现人脸识别搜索
  • 【论文阅读】FreeU: Free Lunch in Diffusion U-Net
  • TypeScript实战——ChatGPT前端自适应手机端,PC端
  • 自定义ORM(mybatis)源码(六)-类型处理器
  • Linux shell编程学习笔记37:readarray命令和mapfile命令
  • GDB:强大的GNU调试器
  • 综述 2022-Egyptian Informatics Journal:电子健康记录的安全和隐私
  • PHP数组定义和输出
  • MySQL中已经有了Binlog,为啥还要有Redo Log
  • Java数据结构-模拟ArrayList集合思想,手写底层源码(1),底层数据结构是数组,编写add添加方法,正序打印和倒叙打印
  • MyBatis-Plus如何 关闭SQL日志打印
  • 单元测试框架jUnit
  • 微软 Visual Studio 迎来 AI 建议命名功能
  • 【排序算法】C语言实现选择排序与冒泡排序
  • 设计模式之-原型模式,快速掌握原型模式,通俗易懂的理解原型模式以及使用场景
  • 数据结构之进阶二叉树(二叉搜索树和AVL树、红黑树的实现)超详细解析,附实操图和搜索二叉树的实现过程图
  • SpringIOC之LocaleContext
  • 前端案例—antdDesign的Select多选框组件加上全选功能
  • 个人财务工具、密钥管理平台、在线会计软件、稍后阅读方案 | 开源专题 No.51
  • HBase基础知识(二):HBase集群部署、HBaseShell操作
  • C 标准库 - <time.h>
  • 养老院自助饮水机(字符设备驱动)
  • Jenkins 构建触发器指南
  • 通用的java中部分方式实现List<自定义对象>转为List<Map>
  • Python---静态Web服务器-返回固定页面数据
  • react v-18父组件调用子组件的方法和数据
  • Linux——缓冲区