Results 1 to 3 of 3

Thread: Qt on iOS: display all images on the device

  1. #1
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Qt on iOS: display all images on the device

    Hello,

    I want to fetch all the images on an iOS device and display them in a GridView. I am aware of two methods for instantiating a vanilla iOS ImagePicker from Qt, but this is insufficient because I want to do multi-selection and UIImagePickerController apparently does not support this!

    What I tried to do instead (using the Photos framework, because the Assets Library framework is deprecated as of iOS 9.0) was populate a QStringList with image URLs (e.g., file:///var/mobile/rest/of/path/to/IMG_XXXX.jpg) and pass that as the model to a QML view for display in a delegate, per the docs here. Worked great when the delegate was a Label. Yay! Did not work at all when the delegate was an Image. For each path, the complaint was the same: I did not have permission to access the file referenced by the URL. Boo! Hiss!

    Perhaps I jumped the gun at that point, because I turned to cobbling together a minimal solution developed entirely in Xcode (v7.3.1, targeting a device running iOS 9.3.2) using objective-c. Interestingly, you can't display images using the filename in that context either, unless the image is included in your project as an asset. You have to sling the image data itself. Works alright, though there are some performance warts, which is fine for now. But I've applied the brakes, because I would really like to implement this project using Qt in order to target Android in future. So, I have a few questions before truly blazing down the pure Xcode/obj-c path.


    1. Did I miss something in my original efforts using a QStringList passed as the model to a view with delegate? If so, what?
    2. A stock QML Image accepts a url as its source, not the image data. Would subclassing QImage, for example, and registering the subclass as a QML type be a way around this? If so, what is the relationship between NSData * (which is what you get from the Photos framework, and which has a bytes property) and uchar * (which is what the QImage constructor accepts)?
    3. Does it make any sense at all, from a cross-platform deployment perspective, to simply launch a bunch of interconnected iOS view controllers from Qt, i.e., creating an objective-c++ class that has-a instance of the root of the view hierarchy, which spins off everything else in pure objective-c? I don't really like the sound of that, but maybe there are some different opinions?


    Any insights are much appreciated.
    Last edited by Urthas; 9th June 2016 at 20:12. Reason: Added links for cited iOS classes/frameworks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt on iOS: display all images on the device

    Quote Originally Posted by Urthas View Post
    Did I miss something in my original efforts using a QStringList passed as the model to a view with delegate? If so, what?
    Since you are saying these are URLs I would have use a list of QUrl instead of QString

    Quote Originally Posted by Urthas View Post
    A stock QML Image accepts a url as its source, not the image data. Would subclassing QImage, for example, and registering the subclass as a QML type be a way around this? If so, what is the relationship between NSData * (which is what you get from the Photos framework, and which has a bytes property) and uchar * (which is what the QImage constructor accepts)?
    If you have a QImage you can either implement a simple item yourself, e.g. using QQuickPaintedItem as the base to derive from, or provide a QQuickImageProvider.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Urthas (10th June 2016)

  4. #3
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Qt on iOS: display all images on the device

    Quote Originally Posted by anda_skoa View Post
    Since you are saying these are URLs I would have use a list of QUrl instead of QString
    No joy. While this works on the simulator, it does not work on a device. Passing a QUrl to an Image results in the following:

    Qt Code:
    1. QML Image: Cannot open: file:///var/mobile/Media/DCIM/100APPLE/IMG_0048.JPG
    To copy to clipboard, switch view to plain text mode 

    This looks like an app sandbox issue...?

    Quote Originally Posted by anda_skoa View Post
    If you have a QImage you can either implement a simple item yourself, e.g. using QQuickPaintedItem as the base to derive from, or provide a QQuickImageProvider.
    I guess this is my next avenue to try, then.

Similar Threads

  1. Replies: 0
    Last Post: 26th July 2012, 10:32
  2. want to display images from device
    By trupti in forum Qt Programming
    Replies: 0
    Last Post: 30th December 2010, 05:51
  3. Modifying the Display on Device
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 13th April 2006, 05:36
  4. how to export images of Qt/Embedded on Device
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd March 2006, 13:05
  5. Interaction between QT/Embedded and LCD display device
    By mahe2310 in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 22nd February 2006, 10:37

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.