Getting invalid path from file dialog
-
Hey, I'm on windows and paths I get from qml file dialogs are in the format "File:///C/User/..." (notice the 3 /). When converting it to a
QUrland then callingpath()on it, it gives me an invalid path like "/C/User/...", does anyone have an idea how to correct approach to do this would be? -
@JonB Apologies. I have multiple problems with paths across my project while porting it to windows. I have fixed the previous problem, but in the case just described,
toLocalFile()does not work.@Creaperdown
Start by testing with literals what will work. I expectedfile:///C:/Users/...to work. You have now introducedfile://C:/Users/.... -
Hey, I'm on windows and paths I get from qml file dialogs are in the format "File:///C/User/..." (notice the 3 /). When converting it to a
QUrland then callingpath()on it, it gives me an invalid path like "/C/User/...", does anyone have an idea how to correct approach to do this would be?@Creaperdown
Are you wanting a local file path from the Url? What doesQUrl::toLocalFile()return?The 3
/s are expected. But I thought there would be an extra:for the drive:file:///C:/User/.... -
@Creaperdown
Are you wanting a local file path from the Url? What doesQUrl::toLocalFile()return?The 3
/s are expected. But I thought there would be an extra:for the drive:file:///C:/User/....@JonB
toLocalFile()seems to return the correct thing. What exactly is the difference betweenpath()andtoLocalFile()? I have checked the docs but I do not get the exact difference, and when I should use what. -
@JonB
toLocalFile()seems to return the correct thing. What exactly is the difference betweenpath()andtoLocalFile()? I have checked the docs but I do not get the exact difference, and when I should use what.@Creaperdown
I think you will find thatQUrl::path()returns a Url path (probably with schema removed), not a (local) file path which you seemed to expect it to do?localPath()converts from Url to file path. -
@Creaperdown
I think you will find thatQUrl::path()returns a Url path (probably with schema removed), not a (local) file path which you seemed to expect it to do?localPath()converts from Url to file path.@JonB I don't get it. I have a string like
file://C:/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.pdfand I simply want the actual path to it, with no scheme.
toLocalFileis gicing me//c/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.PDF 1.5for some reason andpath()gives me/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.PDF 1.5.What can I do to just get the path to my file:
C:/Users/...? -
@JonB I don't get it. I have a string like
file://C:/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.pdfand I simply want the actual path to it, with no scheme.
toLocalFileis gicing me//c/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.PDF 1.5for some reason andpath()gives me/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.PDF 1.5.What can I do to just get the path to my file:
C:/Users/...?@Creaperdown said in Getting invalid path from file dialog:
I don't get it. I have a string like
file://C:/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.pdfCan you please start being consistent in what you report, since it is critical. You begin by telling us
format "File:///C/User/..." (notice the 3 /).. Now you show it with 2//s. You also saidtoLocalFile() seems to return the correct thing. Now you say it does not. -
@Creaperdown said in Getting invalid path from file dialog:
I don't get it. I have a string like
file://C:/Users/prtnp/Librum/build/librum_localLibraries/13824929713553088125/ac17af33-67b7-4b57-a6eb-e7bb69cc0d3f.pdfCan you please start being consistent in what you report, since it is critical. You begin by telling us
format "File:///C/User/..." (notice the 3 /).. Now you show it with 2//s. You also saidtoLocalFile() seems to return the correct thing. Now you say it does not.@JonB Apologies. I have multiple problems with paths across my project while porting it to windows. I have fixed the previous problem, but in the case just described,
toLocalFile()does not work. -
@JonB Apologies. I have multiple problems with paths across my project while porting it to windows. I have fixed the previous problem, but in the case just described,
toLocalFile()does not work.@Creaperdown
Start by testing with literals what will work. I expectedfile:///C:/Users/...to work. You have now introducedfile://C:/Users/.... -
@Creaperdown
Start by testing with literals what will work. I expectedfile:///C:/Users/...to work. You have now introducedfile://C:/Users/....@JonB Thank you. I have gone over it again, realized that all the paths I get from Qml are in the format "file:///" and that it only accepts paths with in the format "file:///", then I have found that
toLocalPathseems to convert it to what I want and I changed it accordingly -
C Creaperdown has marked this topic as solved on
-
@JonB Thank you. I have gone over it again, realized that all the paths I get from Qml are in the format "file:///" and that it only accepts paths with in the format "file:///", then I have found that
toLocalPathseems to convert it to what I want and I changed it accordingly@Creaperdown
I don't use QML, but if file dialog returns Urls of formfile://but it needs to befile:///that would be strange/unhelpful. But I don't know. -
@Creaperdown
I don't use QML, but if file dialog returns Urls of formfile://but it needs to befile:///that would be strange/unhelpful. But I don't know.@JonB It would be a bug since the schema is
file://(two/) and the path is/foo/bar. And since the path must always start with a/it'sfile:///C:/foo/bar- everything else is wrong.