0

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

harsh9607
  • 3
  • 3
  • 1
    DO NOT post images of code, data, error messages, etc.—copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text. For more information please see the Meta FAQ entry [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557) – iam_peter Apr 17 '23 at 10:40
  • you probably have to begin your custom component name with an uppercase letter, see more info [here](https://doc.qt.io/qt-6/qtqml-documents-definetypes.html#defining-an-object-type-with-a-qml-file) . – folibis Apr 17 '23 at 10:41

1 Answers1

0

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.

iam_peter
  • 3,205
  • 1
  • 19
  • 31