Solved QQmlApplicationEngine failed to load component
-
I use Qt in VS 2017 widows 10. here is code
and here is the error
what is the problem?
-
The code you're showing does not contain any errors.
Loading of main.qml fails at runtime, which suggests that:
- QRC file was not compiled
- QRC file was not included in the compiled binary
- main.qml is not in the QRC file
-
@sierdzio can you explain more, please?
-
But what should I explain?
I see you are using Visual Studio, so your setup is probably unusual. I do not know what build system you are using (qmake, cmake, something else?). I do not know if you are using QRC file at all (are you?). I have not seen the code of your QRC file, nor your build system files (*.pro or CMakeLists.txt). I can't guess all that.
-
@sierdzio I add .qrc and .qml file to my project. but I think this address "qrc:/main.qml" can not be found, why?
-
Because it's either wrong (do you have
main.qml
file? Is it added to QRC? Is the path and QRC syntax correct?) or the resource file is not properly added / linked into the binary.Since you have still not shown any code, I can only keep guessing.
-
@sierdzio here is my resource
-
See the "Resource URL" field: this is what you need to paste into your source code.
So it's:
engine.load(QUrl("qrc:/qrc/mian.qml"));
Notice it's
mian
and and notmain
- you've made a typo.BTW. In the future, please paste code, not pictures. This way I can copy-paste and tweak your stuff to help you, instead of typing everything myself.
-
This post is deleted! -
@sierdzio said in QQmlApplicationEngine failed to load component:
qrc:/qrc/mian.qml
problem solved, thanks