How to load png image in qml from an absolute path?

Viewed 26

I have a problem trying to load an image from an absolute path from qml. (from a relative path everything goes well)

Image {
    id : myimage

    source: qsTr("qrc:///")+imagePath
}

My image path is a well defined windows path. I tried many suggestions that I found while googling:
Like starting with file:/// or with qrc:///
Nothing I found worked. It can not load the image.

Is there something I am missing here?

1 Answers

The absolute path you'll want to be using is formatted as a URI like documented here: Windows File URI

Try something like: source: "file:///c:/mypath/myimage.png"

Related