QFiledialog returns forward slashes instead of backslashes.
On Windows, the QFileBrower seems to return the name of the selected file or directory with forward slashes instead of backslashes as the directory separator, e.g. D:/programFiles/xyz/file.doc.
In certain parts of the my code, i check if the path is an absolute or relative path and this fails , because the code expects a backslash.
Can i have a way where i would get the backslash in the path irrespective of OS.
Thanks.
Re: QFiledialog returns forward slashes instead of backslashes.
HI,
internally Qt uses UNIX directory separtor '/'. To convert in "native" form you must use QDir::toNativeSeparators.
You use Qt or your custom code to check if path is relative or absolute?
Re: QFiledialog returns forward slashes instead of backslashes.
Quote:
Originally Posted by
vaibhav
In certain parts of the my code, i check if the path is an absolute or relative path and this fails , because the code expects a backslash.
As mcosta says, QFileBrowser will always uses forward slashes regardless of OS. This makes it easier to write path handling code (no need to escape the backslashes or worry about the OS your running on).
You can therefore either replace all forward slashes with backslashes, or just use Qt functions such as isAbsolutePath and isRelativePath rather than writing your own.