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.qmlto be able to access variables created inmain.qmlin theCan.qmlfile: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.qmlto be able to access variables created inmain.qmlin theCan.qmlfile: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
QMLdir 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
QMLdir 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
QMLdirectory ,and this didnt work. importing works through :0 -
M MaximBozek has marked this topic as solved on
-
@Pl45m4 wow, thanks this worked now. Also tried putting new .qml files in that
QMLdirectory ,and this didnt work. importing works through :0You can also add your
main.qmlto the resources.
The QML directory withmain.qmlis created when starting a new QML project in QtCreator.