Fail to Qt.createComponent in qml
-
Hello guys,
I try to load a qml file dynamically, but failed. The component status keeps "Component.Loading". And the output an error string:
qt.tlsbackend.ossl: Failed to load libssl/libcrypto
qml: Error loading component: e:/QT/abc/my.qml:-1 Network errorFor the first error, "Failed to load libssl/libcrypto", I put the QT's bin dir to environment "path", this error disappear. But the second one, "-1 Network error" keeps the same.
I can successfully create a component if the qml file is a "qrc:/xxx.qml", also can create from C++ code. Qt version is 6.4.2.
Please give some suggestion. Thanks.
Code is like this:onClicked: { var url = Qt.resolvedUrl("E:/QT/abc/my.qml"); console.log("url = ", url) var comp = Qt.createComponent(url); console.log("comp = " + comp) console.log("comp.status = " + comp.status) if (comp.status == Component.Error) { console.log("Error loading component:", comp.errorString()); } if (rb.comp.status === Component.Ready) { var params = { } var item = rb.comp.createObject(rootItem, params); } } -
See if you can make it as Qt.resolvedUrl("file:///E:/QT/abc/my.qml")
Added "file:///" for qml file -
H Hit Tiger Tonight has marked this topic as solved on
-
See if you can make it as Qt.resolvedUrl("file:///E:/QT/abc/my.qml")
Added "file:///" for qml file@dheerendra Thanks. It works. So, any time when you access local file from qml, must add this prefix to url ?