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

Thiago Macieira thiago.macieira at intel.com
Thu Oct 26 00:27:50 CEST 2017


On Wednesday, 25 October 2017 14:14:50 PDT ekke wrote:
> You're right - must be blind - Got the QFileInfo and of course then
> QFile also can open and read the file
> 
> now only one problem left: HowTo display this file as Image in QML ?

I think there's a proper URL format for them. I don't know, since I don't 
write QML code nor for any mobile platform, so this issue has never occurred 
to me. Others may chime in.

The only thing you shouldn't do is this:

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

NEVER form URLs from file paths by concatenation. Always use 
QUrl::fromLocalFile() [and whatever passes for QML's equivalent] to make sure 
that special characters get quoted properly.

Special characters like '?':

> for Photos from assets-library I'm getting QML Image: Cannot open:
> file://assets-library//asset/asset.PNG?id=32E17445-91B9-48FE-81C6-13D4E2F015
> 54&ext=PNG

Your file was called

assets-library://asset/asset.PNG?
id=32E17445-91B9-48FE-81C6-13D4E2F01554&ext=PNG

The URL you formed resulted in

	host = "assets-library"
	path = "//asset/asset.PNG"
	query = "id=32E17445-91B9-48FE-81C6-13D4E2F01554&ext=PNG"

Whereas if you had used QUrl::fromLocalFile, you'd have got

file:assets-library://asset/asset.PNG
%3Fid=32E17445-91B9-48FE-81C6-13D4E2F01554&ext=PNG

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list