Solved Undefined ClickableImage type
-
This is kind of usually happening problem when I read Qt material and tried to run or parse its samples: xxx is not a type.
This time I got sample from "Qt5 Cadaques" and it contains ClickableImage element. I parsed it using qmlscene but got "ClickableImage is not a type"My Qt installation is 5.11 and the imported command is to import QtQuick 2.5. Even I changed it to QtQuick 2.11, the same thing. I believe the book is much older than Qt 5.11. So, what's wrong with it? How do deal with such kinds of troubles?
-
Well, the QML engine is right - there is no ClickableImage component in Qt, and never has been.
I suspect the example instructs you somewhere to create a new QML file, called ClickableImage.qml, right? Then QML engine will be able to find it, as long as it's in the same directory as your main.qml.
-
Yes, I found a snippet marked as ClickableImage.qml. That must the the file which I must put at the same folder as my target qml file.
But I still wonder why there are some elements in Qt tutorial, such as Button, which must be very basic, was seen as 'not a type'. Do you think I need to find some modules, like Button.qml at some places of the tutorial? -
There is button in
QtQuick.Controls 1
andQtQuick.Controls 2
, you can add them by usingimport
statement. The tutorial might, however, add a custom Button.qml. I can't say for sure without seeing the actual tutorial...