Problem with adding another qml file
-
wrote on 21 Aug 2024, 07:48 last edited by
Hello
I have problem with adding another qml file to my project.
Generally I have main.qml file with main window and second qml file named kafelek.qml with Item, but after adding this file to my project and resource i have error like this:QQmlApplicationEngine failed to load component qrc:/WebAPT/main.qml:145:25: Kafelek is not a type
Below screenshot with prove, that my second qml file is added to resource, how can i fix it?
-
wrote on 21 Aug 2024, 13:02 last edited by
By looking at the file structure, QML folder also has two files with same name and .qrc file also has two file with the same name, can you remove QML file folder(by right click on the kafelek, and main.qml) and chage the main.qml qrc path in main.cpp so main.cpp loads main.qml from .qrc file. . both qml files resides in .qrc file and you are free to go.
-
wrote on 21 Aug 2024, 13:26 last edited by Durugesha
-
wrote on 22 Aug 2024, 11:39 last edited by
I found solution without creating resource. The pro file must by eddited like this with example in my example with Kafelek.qml
After space write filename with extension in resource.files :)QT += quick SOURCES += \ main.cpp resources.files = main.qml Kafelek.qml resources.prefix = /$${TARGET} RESOURCES += resources # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ Kafelek.qml \ images/logo.png
-
1/4