Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Fail to Qt.createComponent in qml
Qt 6.11 is out! See what's new in the release blog

Fail to Qt.createComponent in qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 917 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hit Tiger Tonight
    wrote on last edited by
    #1

    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 error

    For 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);
        }
    }
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      See if you can make it as Qt.resolvedUrl("file:///E:/QT/abc/my.qml")
      Added "file:///" for qml file

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      H 1 Reply Last reply
      2
      • H Hit Tiger Tonight has marked this topic as solved on
      • dheerendraD dheerendra

        See if you can make it as Qt.resolvedUrl("file:///E:/QT/abc/my.qml")
        Added "file:///" for qml file

        H Offline
        H Offline
        Hit Tiger Tonight
        wrote on last edited by
        #3

        @dheerendra Thanks. It works. So, any time when you access local file from qml, must add this prefix to url ?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved