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

ekke ekke at ekkes-corner.org
Wed Oct 25 19:42:51 CEST 2017


I need access to Images stored at iPhone to display as QML Image and
upload them to REST Service.
Qt 5.9.x, iOS 10+

So I added this to Info.plist:
<key>NSPhotoLibraryUsageDescription</key>

last entry of QStandardPath::PicturesLocation gives me access to
assets-library://
and all Images from PhotoLibrary are listed

QFileInfo then gives me this as filename:
"asset.PNG?id=E8CE839A-29EA-42B2-A8FD-89B57ABEC765&ext=PNG"
and this as path:
"assets-library://asset/asset.PNG?id=E8CE839A-29EA-42B2-A8FD-89B57ABEC765&ext=PNG"
I'm also getting the correct size of the Images from QFileInfo

But I couldn't figure out HowTo get the local FileName and Path

found this Forum post
https://forum.qt.io/topic/47495/upload-ios-image-with-qt/8
and followed the advice there and tried:

QString path("file:assets-library:/asset/"+fileInfo.fileName());
QUrl url(path);
path = url.toLocalFile();

the path then looks as posted in forum post:
"file:assets-library:/asset/asset.PNG?id=FB873B83-78E1-4B18-8601-0CD2CBD92308&ext=PNG"
but url.toLocalFile() only gives
"assets-library:/asset/asset.PNG"

Any idea HowTo get access to the Photos ?

thx

ekke




More information about the Interest mailing list