Solved QImage from file path
-
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.
-
'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:///
-
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";
}
}