当前位置:首页 >> 编程语言 >> 【Qt之Quick模块】5. QML基本类型及示例用法,iphone4必备软件

【Qt之Quick模块】5. QML基本类型及示例用法,iphone4必备软件

cpugpu芯片开发光刻机 编程语言 1
文件名:【Qt之Quick模块】5. QML基本类型及示例用法,iphone4必备软件 【Qt之Quick模块】5. QML基本类型及示例用法 QML格式 QML基本类型

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

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) // 输出点对象的坐标值到控制台}}

结果:

协助本站SEO优化一下,谢谢!
关键词不能为空
同类推荐
«    2025年12月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接