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. QImage + iOS open from locale path
Forum Updated to NodeBB v4.3 + New Features

QImage + iOS open from locale path

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 545 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
    Lynx
    wrote on last edited by Lynx
    #1

    Hello, I'm write application for iOS. I get image path via QML FileDialog ("file:assets-library://asset/asset.JPG%3Fid=C6E6...77E9&ext=JPG")) and send to C++, I get message "Image not load". what I do wrong ?
    qml:

        FileDialog {
            id: fileDialog
            title: "Please choose a file"
            folder:StandardPaths.standardLocations(StandardPaths.PicturesLocation)[2]//shortcuts.home
            selectExisting: true
            onAccepted: {
                //console.log(file)
                imageProcessor.processImage_file(fileDialog.file)
                fileDialog.close()
            }
            onRejected: {
                console.log("Canceled")
                fileDialog.close()
            }
        }
    

    C++:

    void ImageProcessor::processImage_file(const QString &path)
    {
        QString assetsPath=path;
        QImage myImage;
        QUrl url(assetsPath);
        assetsPath = url.toLocalFile();
        myImage.load(assetsPath);
        if( !myImage.isNull()) 
        {
                  //........
        }
        else qDebug()<<"Image not load";
    
    1 Reply Last reply
    0
    • Quang PhuQ Offline
      Quang PhuQ Offline
      Quang Phu
      wrote on last edited by
      #2

      I have same issue, I used Filedialog as below:

       FileDialog {
                                  id: fileOpenDialog
      
                                  title: "Select an image file"
                                  folder: Qt.platform.os == "ios" ? shortcuts.pictures :shortcuts.documents
                                  nameFilters: [ "Image files (*.png *.jpeg *.jpg)" ]
                                  onAccepted: {
                                      console.log(fileOpenDialog.fileUrl);
                                      avatar.source = fileOpenDialog.fileUrl;
                                }                               
      }
      

      But when I try to choose an image from iOS device, the path is
      qml: file:assets-library://asset/asset.HEIC%3Fid=CC95F08C-88C3-4012-9D6D-64A413D254B3&ext=HEIC
      Then I can't open it in Image as set avatar.source = fileOpenDialog.fileUrl;
      Anyone have solution?

      1 Reply Last reply
      0
      • Quang PhuQ Offline
        Quang PhuQ Offline
        Quang Phu
        wrote on last edited by
        #3

        Then I try get a PNG file instead HEIC, but I still got error, and there is a strange thing, this is my log:

        qml: file:assets-library://asset/asset.PNG%3Fid=C8465D9C-B920-4400-9C92-2B34ADD5127C&ext=PNG
        qrc:/pages/UserInfoPopUp.qml:156:21: QML Image: Error decoding: file:assets-library://asset/asset@3x.PNG%3Fid=C8465D9C-B920-4400-9C92-2B34ADD5127C&ext=PNG: Unsupported image format
        

        I don't know why as log, I passed asset.PNG but actually image got asset@3x.PNG
        Anyone has idea and solution for these?

        1 Reply Last reply
        0
        • Quang PhuQ Offline
          Quang PhuQ Offline
          Quang Phu
          wrote on last edited by
          #4

          More information about environment:
          Qt 5.14.0
          Xcode 11.3.1
          iOS simulator: iPhone 6 13.3
          up....

          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