[Interest] Qt iOS - HowTo get access to Images stored at device

ekke ekke at ekkes-corner.org
Thu Oct 26 08:07:10 CEST 2017


Hi Michael,

it's the other way around (C++ to QML)

from

QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()


I create QDir and from entryInfoList() I'm getting QFileInfo and use
.filePath() to open QFile, so I can upload the Image to REST Service
This works on Android for all Locations and also iOS assets-library

Now I also want to display this filePath as QML Image
I did it this way and it worked on Android, also on iOS if dealing with
App Data, but not for assets-library

source: "file://"+currentFile.path

BTW: most examples I found are forming the Url for QML Image source by
concatenation

from Thiago I learned that I shouldn't do this, so I tried

source: Qt.resolvedUrl("file://"+currentFile.path)

but this seems also to be wrong because I'm again forming the URL by
concatenation

so now I'm having two questions:
a) HowTo set QML Image source the correct way without concatenation
b) what's the correct URI under iOS for assets-library to be used in QML
Image source

thx

ekke


Am 25.10.17 um 20:19 schrieb Michael R Nelson:
> Hi,
>
> Here's how I make use of path passed as QString from QML context:
>
> void MyClass::saveImage(const QString &path)
> {
>    QFileInfo fi(QUrl(path).toLocalFile());
>    if (fi.exists())
>       // refer to file as fi.filePath();
> }
>
> Hope this helps.
>
> Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171026/a4427d9c/attachment.html>


More information about the Interest mailing list