Accessing to a resource set in qt_add_qml_module from C++
-
Hi all.
I'm trying to access to a resource configured in qt_add_qml_module() from C++.
My Cmake looks like this
qt_add_qml_module(myApp URI myApp VERSION 1.0 QML_FILES Main.qml another.qml RESOURCES resources/web/auth/index.html ) C++ ------ QString qstr_uurl = "qrc:/myApp/resources/web/auth/index.html"; QUrl url = QUrl(qstr_uurl); if (!url.isValid()) { qDebug("Invalid URL: %s", qUtf8Printable(url.toString())); return QHttpServerResponse("text/plain", "File not found", QHttpServerResponse::StatusCode::NotFound); }
It's failing... I'm not sure how this resource should be accessed.
-
The default path of resources with
qt_add_qml_module
should now beqrc:/qt/qml/<module name>
.When in doubt you can use
QDirIterator
to recursively iterate over yourqrc:
folder to see what's in it. Using GammaRay is also a solution.