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. Problems loading QML files from .qrc resource
Forum Updated to NodeBB v4.3 + New Features

Problems loading QML files from .qrc resource

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 2.7k Views 2 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.
  • E Offline
    E Offline
    Erlend E. Aasland
    wrote on last edited by
    #1

    Hi,

    I've got a resource file that contains a couple of images, a QSS style sheet and a QML file. The image files and the style sheet loads without problems, but the QML file will not load when the application is depoloyed to other computers. The QML file loads fine on my development machine, both when running the program from Qt IDE and when installed on my dev machine. I suspect this has something to do with QUrl. My code is as follows:

    QQuickView *view = new QQuickView;
    view->setSource(QUrl("qrc:/qml/MyComponent.qml"));
    

    This is the relevant contents of the .qrc file:

    <RCC>
        <qresource lang="qml" prefix="/qml">
            <file>MyComponent.qml</file>
        </qresource>
    </RCC>
    
    1 Reply Last reply
    0
    • E Offline
      E Offline
      Erlend E. Aasland
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • E Offline
        E Offline
        Erlend E. Aasland
        wrote on last edited by
        #3

        Ok, after a little bit of debugging, I'm getting a little bit closer to a solution:

        I've attached a callback to the statusChanged() signal of QQuickView. On my development computer, everything is nice and neat, and the QQuickView reaches the QQuickView::Ready state without problems.

        On my deployment computer, QQuickView stops at the QQuickView::Error state, with the error list being:

        qrc:/qml/MyComponent.qml:1:1: module "QtQuick" is not installed
        qrc:/qml/MyComponent.qml:2:1: module "QtQml.Models" is not installed

        I've got these imports in my .qml:

        import QtQuick 2.0
        import QtQml.Models 2.1
        

        I've deployed exactly the same Qt 5.9 dll's that I've got on my development machine.

        Just for the record: Both my dev computer and my deployment computer run Windows 7 Pro.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Did you also deployed the corresponding QML stuff ? windeployqt has an option for that. Pass it the path to your application QML files and it will deploy all the necessary related files.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Did you also deployed the corresponding QML stuff ? windeployqt has an option for that. Pass it the path to your application QML files and it will deploy all the necessary related files.

            E Offline
            E Offline
            Erlend E. Aasland
            wrote on last edited by
            #5

            @SGaist No, I didn't, and that was the problem. Solved it yesterday, but fortgot to update this post. I haven't checked out windeployqt yet, but will do! Currently I'm using InnoSetup.

            E

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              InnoSetup is for creating installers. windeployqt is to give you a folder with all that is needed to run your application. You can use both to create your installer.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 1 Reply Last reply
              1
              • SGaistS SGaist

                InnoSetup is for creating installers. windeployqt is to give you a folder with all that is needed to run your application. You can use both to create your installer.

                E Offline
                E Offline
                Erlend E. Aasland
                wrote on last edited by
                #7

                @SGaist Right, thanks again!

                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