Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML absolute images path work on windows , while don't work on mac , why
Qt 6.12 LTS is out! See what's new in the release blog

QML absolute images path work on windows , while don't work on mac , why

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 4.2k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    in order to provide skin options for applications , I couldn't put the images in qrc files , while I put qml files in qrc files , because I want to hide these qml files to customers , I pass the absoulte path (get from QDir::currentPath()) and use QDeclarativeContext::setContextProperty("mainWidget",this) to pass the absolute path to qml , and in my qml files , I construct the images path like this ,source:mainWidget.absolutePath +"/images/top_bg.png" , and it works well on windows , in debug folder , I put the images folder which contains all the images in debug folder with exe in the same folder, and it can find the images and show the application UI well , while on mac , at first I try to make with bundle option , it can't work , then I make without bundle option(in pro file , with CONFIG -= app_bundle ) , and still it can't find the images , and it said errors :
    qrc:/qml/BottomStatusLine.qml:8:5: QML Image: Cannot open: qrc:/Users/macmaya/images/statebar_bg.png
    qrc:/qml/NDuoDemo.qml:20:9: QML BorderImage: Cannot open: qrc:/Users/macmaya/images/shadow.png

    It automatically take it as the qrc source files , because the qml files are in qrc , while it can work on windows , while it can't work on
    mac , and if I want to make it as bundle option , how could I do to make it recognize the images . thanks guys .

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You need put the images to YourAppName.app/Contents/MacOS, have a look at how do deployment on Mac OS X on document.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi,
        I'm working on MacOS X and I have the same problem. I want my QML file to be located in the appbundle, but my images can't be located in the bundle. Because it's the users who choose them at runtime like if I was writting a paint in QML.

        I'm using Qt5 and I'm running out of ideas :(. The only thing I need is to be able to show external image (out of the app bundle).
        Thanks for reading me :).

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