qml坑之invalid property name

本文介绍了使用QML文档定义自定义对象类型的正确方法。强调了对象类型名称必须以大写字母开头,而对象ID和属性名则需以小写字母开始。遵循这些规则对于避免错误至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

新建一个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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值