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 from file path
Qt 6.11 is out! See what's new in the release blog

QImage from file path

Scheduled Pinned Locked Moved Solved Mobile and Embedded
qimageuiimage qml
3 Posts 2 Posters 10.9k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    Mitchell
    wrote on last edited by A Former User
    #1

    I have a path that i get back from selecting an image from the camera roll. I can take that path and add it to the source: "path", and the image will show. Now i take that same string and try and load a QImage. It says the file does not exist.

    file:/var/mobile/Applications/41315920-5A93-4C3E-A9DA-79E295BFE99D/Documents/capture.png

    this is the path that i am using. I am assuming it has to do with the fact that it is specific to the IOS device i am using. So i can't use the QImage myImage(path). So does anyone know how i should do this? Any help would be great.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      'file:/' in the beginning of the path means it is a URL, not a file path. QImage might not understand that (I'm not sure). And is should have more slashes: file:///

      (Z(:^

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mitchell
        wrote on last edited by
        #3

        Thank you so much. It is in fact a URL and you can use this to load it into a Image.

        void dataSender::fetchImage(QString filePath)
        {
        const QUrl url =filePath;
        if (url.isValid()) {
        qDebug() << "Valid URL: " ;
        QString test = url.path();
        QImage myImage(test);
        qDebug() << "Image Size " << myImage.size();
        }
        else{
        qDebug() << "the url is invalid";
        }
        }

        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