“hoverbutton” 无效属性名称。(M16) | Qt 快速 | //@disable-check M16 解决方案无效。

huangapple go评论108阅读模式
英文:

Invalid Property name "hoverbutton". (M16) | Qt quick | //@disable-check M16 solution not working

问题

I am creating a simple image viewer QT Quick application on QT6 using QT Creator 10.0.0.
我正在使用QT Creator 10.0.0在QT6上创建一个简单的图像查看器QT Quick应用程序。

I have two Qml files namely main.qml and hoverButton.qml.
我有两个Qml文件,分别是main.qml和hoverButton.qml。

When I am trying to instantiate the hoverbutton inside my main.qml file I get the error - Invalid property name "hoverButton". M16.
当我尝试在main.qml文件中实例化hoverbutton时,我收到错误消息 - 无效的属性名称"hoverButton"。M16。

If I type //@disable-check M16 , the error message goes away but on building the projects I get the error as shown below.
如果我输入***//@disable-check M16***,错误消息消失了,但在构建项目时,我收到如下所示的错误。

QQmlApplicationEngine failed to load component
qrc:/simple-image-viewer/Main.qml:30:13: Cannot assign to non-existent property "hoverButton"
15:14:04: C:\Users\usero\Documents\QTProjects\build-simple-image-viewer-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\appsimple-image-viewer.exe exited with code -1

Known solution not working
已知的解决方案不起作用

the CMAKE file looks like this
CMAKE文件如下所示

the code of hoverButton.qml is
hoverButton.qml文件的代码如下所示

英文:

I am creating a simple image viewer QT Quick application on QT6 using QT Creator 10.0.0.
I have two Qml files namely main.qml and hoverButton.qml . When I am trying to instantiate the hoverbutton inside my main.qml file I get the error - Invalid property name "hoverButton". M16.

Error message

If I type //@disable-check M16 , the error message goes away but on building the projects I get the error as shown below.

QQmlApplicationEngine failed to load component
qrc:/simple-image-viewer/Main.qml:30:13: Cannot assign to non-existent property "hoverButton"
15:14:04: C:\Users\usero\Documents\QTProjects\build-simple-image-viewer-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\appsimple-image-viewer.exe exited with code -1

Known solution not working

the CMAKE file looks like this
CMAKE File code

the code of hoverButton.qml is
hoverButton.qml file

答案1

得分: 0

请查看文档

> 要创建一个对象类型,QML 文档应该被放置在一个文本文件中,文件名为<TypeName>.qml,其中<TypeName>是所需的类型名称。类型名称必须满足以下要求:
>
> - 它必须由字母数字字符或下划线组成。
> - 它必须以大写字母开头。

在您的情况下,hoverButton 预期是一个属性,而不是一个类型,因此会出现错误消息。

英文:

Have a look at the documentation.

> 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. The type name has the following requirements:
>
> - It must be comprised of alphanumeric characters or underscores.
> - It must begin with an uppercase letter.

In your case hoverButton is expected to be a property instead of a type hence the error message.

huangapple
  • 本文由 发表于 2023年4月17日 18:06:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76033974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定