Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. {Select image from iOS photo library}How can i open the photo library and have the user select an image and process/upload it?
Forum Updated to NodeBB v4.3 + New Features

{Select image from iOS photo library}How can i open the photo library and have the user select an image and process/upload it?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 735 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LoudestBoi
    wrote on last edited by
    #1

    This is all my current code but it launches the files app on iOS, i want it to run the photo library:
    CODE:
    bool BackEnd::prepareImage(QUrl path)
    {
    QFile *file;

    #ifdef Q_OS_ANDROID
    file = new QFile(QQmlFile::urlToLocalFileOrQrc(path));
    #else
    file = new QFile(path.toLocalFile());
    #endif
    
    file->open(QIODevice::ReadOnly);
    QByteArray image = file->readAll();
    
    QString encoded = image.toBase64();
    file->close();
    
    if (encoded.size() < 12000000)
    {
        imageToUploadBase64 = encoded;
        return true;
    }
    else
        return false;
    

    }

    void BackEnd::cancelImage()
    {
    imageToUploadBase64 = "";
    }

    jsulmJ 1 Reply Last reply
    0
    • L Offline
      L Offline
      LoudestBoi
      wrote on last edited by
      #2

      Its for an android port to ios

      J.HilkJ 1 Reply Last reply
      0
      • L LoudestBoi

        This is all my current code but it launches the files app on iOS, i want it to run the photo library:
        CODE:
        bool BackEnd::prepareImage(QUrl path)
        {
        QFile *file;

        #ifdef Q_OS_ANDROID
        file = new QFile(QQmlFile::urlToLocalFileOrQrc(path));
        #else
        file = new QFile(path.toLocalFile());
        #endif
        
        file->open(QIODevice::ReadOnly);
        QByteArray image = file->readAll();
        
        QString encoded = image.toBase64();
        file->close();
        
        if (encoded.size() < 12000000)
        {
            imageToUploadBase64 = encoded;
            return true;
        }
        else
            return false;
        

        }

        void BackEnd::cancelImage()
        {
        imageToUploadBase64 = "";
        }

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @LoudestBoi Use QStandardPaths::PicturesLocation to get the pictures location via https://doc.qt.io/qt-5/qstandardpaths.html#standardLocations Then you can read files there.
        I think you also have to request access rights via Info.plist.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • L LoudestBoi

          Its for an android port to ios

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @LoudestBoi take a look at this topic and the example code by @benlau

          https://forum.qt.io/topic/75700/ios-photo-gallery-view-in-qt/7

          should get you started/contain all you need


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          L 1 Reply Last reply
          2
          • J.HilkJ J.Hilk

            @LoudestBoi take a look at this topic and the example code by @benlau

            https://forum.qt.io/topic/75700/ios-photo-gallery-view-in-qt/7

            should get you started/contain all you need

            L Offline
            L Offline
            LoudestBoi
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved