Nominate our 2022 Qt Champions!

Problems loading QML files from .qrc resource

  • 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;

    This is the relevant contents of the .qrc file:

        <qresource lang="qml" prefix="/qml">

  • This post is deleted!

  • 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.

  • Lifetime Qt Champion


    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.

  • @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.


  • Lifetime Qt Champion

    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.

  • @SGaist Right, thanks again!

Log in to reply