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

Jeffrey Brendecke jeffrey.brendecke at gmail.com
Thu Oct 26 14:52:11 CEST 2017


> On 26. Oct 2017, at 13:10, interest-request at qt-project.org wrote:
> 
> From: ekke <ekke at ekkes-corner.org <mailto:ekke at ekkes-corner.org>>
> Subject: Re: [Interest] Qt iOS - HowTo get access to Images stored at device
> Date: 26. October 2017 at 08:07:10 GMT+2
> To: "interest at qt-project.org <mailto:interest at qt-project.org>" <interest at qt-project.org <mailto:interest at qt-project.org>>
> 
> 
> 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
> 

Hello Ekke,

It looks like the Asset Library Framework has been deprecated as of iOS 9:

https://developer.apple.com/documentation/photos/phasset?language=objc <https://developer.apple.com/documentation/photos/phasset?language=objc>

The new way to access the assets is through the Photos framework. The above link contains links to the relevant classes. The Photos framework is feature rich and allows you to access images separate from their adjustment data or with the adjustments applied.

The solution involves working with Objective-C++, but using this API is probably unavoidable given that Apple has moved away from managing images as files on a local file system.

I hope this is of help to you,

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


More information about the Interest mailing list