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. QML files not found when deploying on Mac
Forum Updated to NodeBB v4.3 + New Features

QML files not found when deploying on Mac

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.4k 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.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    The Qt Creator log shows this when trying to run a Mac QML app:

    project.app/Contents/MacOS/main.qml:-1 File not found

    There is no scenario I can find where the qml files would end up in this directory in a mac build. How have others set this up? The instructions on this page make it look so easy, but I suspect these instructions were not tried on Mac:

    https://qt-project.org/doc/qt-5.1/qtquickcontrols/qtquickcontrols-overview.html#setting-up-controls-from-c
    "Setting Up Controls under C++"

    They just list the qml file name and it works; but in my experience this is not so easy.

    I could try to use a resource file, however my qml has Image elements that interact image sources in the local filesystem, not in the build system. Putting qml in a resource file seems to require that any images loaded in qml are also in the relative path of the resource file.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      This is true for every operating system, not only Mac: Qt does not manage the QML files for you, you need to do that part yourself. That means that if you are not happy with QRC, you need to deploy QML files by hand/ custom scripts.

      [quote]Putting qml in a resource file seems to require that any images loaded in qml are also in the relative path of the resource file.[/quote]

      True, but that behaviour can be changed with some hardcore hacking (need to reset the context). Example:
      @
      QQmlContext *context = engine()->contextForObject(object);
      context->setBaseUrl(QUrl::fromLocalFile("")); // This resets the QRC reading mode
      @

      (Z(:^

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qttester5
        wrote on last edited by
        #3

        Hm, if I do not use a resource file and just use a simple setup like this:
        @
        QtQuick2ControlsApplicationViewer viewer;
        viewer.setMainQmlFile(QStringLiteral("qml/ajssg-view/main.qml"));
        viewer.show();@

        The qml is properly deployed.

        However as soon as I go to this, it does not work at all as smoothly (or for me yet, at all):
        @
        QApplication app(argc, argv);
        QQmlApplicationEngine engine(QUrl::fromLocalFile("main.qml"));
        return app.exec();@

        I've tried every conceivable path and expression for engine() constructor.

        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