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.
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
the CMAKE file looks like this
CMAKE File code
the code of hoverButton.qml is
hoverButton.qml file
>Solution :
Have a look at the documentation.
To create an object type, a QML document should be placed into a text
file named as .qml where 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.