Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Accessing to a resource set in qt_add_qml_module from C++
Forum Updated to NodeBB v4.3 + New Features

Accessing to a resource set in qt_add_qml_module from C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 320 Views 1 Watching
  • 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.
  • J Offline
    J Offline
    josancardenasm
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peiqi.Liu
      wrote on last edited by Peiqi.Liu
      #2

      Same issue. I don't konw how to use a resource set in qt_add_qml_module, I can't set windowIcon now. Qt is so difficult.

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        The default path of resources with qt_add_qml_module should now be qrc:/qt/qml/<module name>.

        When in doubt you can use QDirIterator to recursively iterate over your qrc: folder to see what's in it. Using GammaRay is also a solution.

        1 Reply Last reply
        1

        • Login

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