qml坑之invalid property name

来源:互联网 发布:网络盒子怎么用 编辑:程序博客网 时间:2024/05/18 00:05

新建一个qml文件,定义一个控件,但是在main.qml中调用报错:invalid property name
原因:调用时的对象名称首字母必须大写

Defining Object Types through QML Documents

“To create an object type, a QML document should be placed into a text file named as TypeName.qml where TypeName is the desired name of the type, which must be comprised of alphanumeric characters or underscores and beginning with an uppercase letter. “

而对象id和对象属性(property)命名首字母必须为小写字母

A value may be assigned to the id attribute of an object instance to allow that object to be identified and referred to by other objects. This id must begin with a lower-case letter or an underscore, and cannot contain characters other than letters, numbers and underscores.

Property names must begin with a lower case letter and can only contain letters, numbers and underscores.

原创粉丝点击