How to use QImage to load a file with name "#.png"?
-
There is a file named "#.png" in my D disk
When I use the following qml code
Image {
source: "file:///D:/#.png"
}
and I directly get an error "QML Image: Cannot open: file:///D://#.png"
but everything is fine if I rename the file name to "1.png", how to solve this problem -
I think the format of file path is incorrect .
For Example,try the following:
D:/#.pngFor more information , follow - link
-
@NixUhs said in How to use QImage to load a file with name "#.png"?:
There is a file named "#.png" in my D disk
When I use the following qml code
Image {
source: "file:///D:/#.png"
}
and I directly get an error "QML Image: Cannot open: file:///D://#.png"
but everything is fine if I rename the file name to "1.png", how to solve this problemYou have to escape hash-tag symbol with
\
(cf https://bugreports.qt.io/browse/QTBUG-68635)
Following should work:Image { source: "file:///D:/\#.png" }
-
Or use
encoreURIComponent
like mentionned at the end of theurl
documentation.