QML Object 自定义的QML组件,首字母必须大写

10 篇文章 0 订阅
2 篇文章 0 订阅

A QML object type is a type from which a QML object can be instantiated.
QML对象类型是可以实例化QML对象的类型。

In syntactic terms, a QML object type is one which can be used to declare an object by specifying the type name followed by a set of curly braces that encompasses the attributes of that object. This differs from basic types, which cannot be used in the same way. For example, Rectangle is a QML object type: it can be used to create Rectangle type objects. This cannot be done with primitive types such as int and bool, which are used to hold simple data types rather than objects.
在语法方面,QML对象类型是一种可以用来声明对象的类型,方法是指定类型名,后跟一组包含对象属性的大括号。这与基本类型不同,基本类型不能以相同的方式使用。例如,Rectangle是QML对象类型:它可以用于创建矩形类型的对象。对于int和bool这样的原语类型无法做到这一点,它们用于保存简单的数据类型而不是对象

Custom QML object types can be defined by creating a .qml file that defines the type, as discussed in Documents as QML object type definitions, or by defining a QML type from C++ and registering the type with the QML engine, as discussed in Defining QML Types from C++. Note that in both cases, the type name must begin with an uppercase letter in order to be declared as a QML object type in a QML file

自定义QML对象类型可以通过创建一个.qML文件来定义,该类型定义为文档类型,如QML对象类型定义中所讨论的,或者通过定义C++中的QML类型,并用QML引擎注册类型,如在从C++定义QML类型时所讨论的。注意,在这两种情况下,类型名必须以大写字母开头,才能在QML文件中声明为QML对象类型

例如:

Rectangle { //首字母大写
}

Text {
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值