QImageReader struggles with some paths
-
Hi,
I'm using a QImageReader to get the image info.
A path to a png ending with the following string works:/photo/test/Hatsune Miku Project DIVA F_10.pngBut the same path with a colon doesn't
/photo/test/Hatsune Miku: Project DIVA F_10.pngThe QImageReader::canRead() function returns false and the errorString() returns "File not found".
Is there some way around this?
-
Hi,
I'm using a QImageReader to get the image info.
A path to a png ending with the following string works:/photo/test/Hatsune Miku Project DIVA F_10.pngBut the same path with a colon doesn't
/photo/test/Hatsune Miku: Project DIVA F_10.pngThe QImageReader::canRead() function returns false and the errorString() returns "File not found".
Is there some way around this?
@Megamouse
What platform is this on? -
Hi,
How do you get the one that is a std::string ?
-
I'm on Windows 11.
This is the log:
QString "C:/Users/Megamouse/Pictures/Hatsune Miku: Project DIVA F_10.png" canRead true QString::fromStdString "C:/Users/Megamouse/Pictures/Hatsune Miku: Project DIVA F_10.png" canRead false@Megamouse
If you are on Windows how is either of those a legal pathname? [To be clear: Windows doesn't allow:in pathnames.] I don't know about whystdStringmakes any difference to the result regardless. -
@SGaist said in QImageReader struggles with some paths:
How do you get the one that is a std::string ?
It's also not working if the path was created as QString in the first place.
Maybe there's some hidden stuff in QString coming from QFileDialog?The path comes from regular c++ directory scan
-
Did you try to compare the content at the lowest level ?
-
@SGaist said in QImageReader struggles with some paths:
How do you get the one that is a std::string ?
It's also not working if the path was created as QString in the first place.
Maybe there's some hidden stuff in QString coming from QFileDialog?The path comes from regular c++ directory scan
@Megamouse
I would check again your understanding that your Windows filename contains an embedded:character.For example, try to create such a filename yourself, from a program or Explorer or whatever.
Have a read of e.g. https://stackoverflow.com/questions/10386344/how-to-get-a-file-in-windows-with-a-colon-in-the-filename. Could the solution there be relevant to your situation, could it actually be a
:-looking character which is not a:? -
Yes. I just did.
Turns out the original path has a FULLWIDTH COLON, while the other one converts it to a regular colon.
The QImageReader thus can't find the file.Turns out the original path has a FULLWIDTH COLON, while the other one converts it to a regular colon.
...which is exactly what the stackoverflow solution talks about...