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

Michael R Nelson mnelson at sutron.com
Wed Oct 25 20:19:56 CEST 2017


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

-----Original Message-----
From: Interest [mailto:interest-bounces+mnelson=sutron.com at qt-project.org] On Behalf Of ekke
Sent: Wednesday, October 25, 2017 1:43 PM
To: interest at qt-project.org
Subject: [Interest] Qt iOS - HowTo get access to Images stored at device

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://urldefense.proofpoint.com/v2/url?u=https-3A__forum.qt.io_topic_47495_upload-2Dios-2Dimage-2Dwith-2Dqt_8&d=DwICAg&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=81ZrscQ2yIyG6ANaI07JBq6GmZkaYdjZEl0tfKL-7tQ&m=Phg22MLI9lgE6ZSovS--7kDgJcUILk7DTC4C9SeKvUg&s=TuwQT6M0uXql8Qi-p22FD-bfz5N3Xjj8sA2QYodmM4E&e=
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

_______________________________________________
Interest mailing list
Interest at qt-project.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.qt-2Dproject.org_mailman_listinfo_interest&d=DwICAg&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=81ZrscQ2yIyG6ANaI07JBq6GmZkaYdjZEl0tfKL-7tQ&m=Phg22MLI9lgE6ZSovS--7kDgJcUILk7DTC4C9SeKvUg&s=61Fr2R3WADIkrErgeLy0KtlXvFEKiDmvnLwN403P1f8&e=

Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.



More information about the Interest mailing list