using QML files as items in main.qml
-
Hi,
I created a qml file, for example
Can.qml
. Then I would call this qml file as a item inmain.qml
to be able to access variables created inmain.qml
in theCan.qml
file:Can { id: can_page visible: false }
I used this in other project and that worked fine.
Now for some reason, I get this error:qrc:/Test_Project_Display/main.qml:41:5: Can is not a type
This is my projects structure:What could be the issue here?
-
Hi,
I created a qml file, for example
Can.qml
. Then I would call this qml file as a item inmain.qml
to be able to access variables created inmain.qml
in theCan.qml
file:Can { id: can_page visible: false }
I used this in other project and that worked fine.
Now for some reason, I get this error:qrc:/Test_Project_Display/main.qml:41:5: Can is not a type
This is my projects structure:What could be the issue here?
@MaximBozek said in using QML files as items in main.qml:
What could be the issue here?
Where is your "Can.qml" file now? The project's
QML
dir only shows themain.qml
.
If the other QML module/file (Can.qml) is not in the directory, you need to import it.Like (I'm not a QML expert)
// main.qml import "qrc:/qml/elements"
-
@MaximBozek said in using QML files as items in main.qml:
What could be the issue here?
Where is your "Can.qml" file now? The project's
QML
dir only shows themain.qml
.
If the other QML module/file (Can.qml) is not in the directory, you need to import it.Like (I'm not a QML expert)
// main.qml import "qrc:/qml/elements"
@Pl45m4 wow, thanks this worked now. Also tried putting new .qml files in that
QML
directory ,and this didnt work. importing works through :0 -
-
@Pl45m4 wow, thanks this worked now. Also tried putting new .qml files in that
QML
directory ,and this didnt work. importing works through :0You can also add your
main.qml
to the resources.
The QML directory withmain.qml
is created when starting a new QML project in QtCreator.