Results 1 to 3 of 3

Thread: QFiledialog returns forward slashes instead of backslashes.

  1. #1
    Join Date
    Mar 2009
    Location
    delhi India
    Posts
    56
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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?
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFiledialog returns forward slashes instead of backslashes.

    Quote Originally Posted by vaibhav View Post
    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.

Similar Threads

  1. make install problem with (back)slashes
    By brazso in forum Qt Programming
    Replies: 1
    Last Post: 1st July 2010, 10:15
  2. Replies: 6
    Last Post: 22nd April 2010, 15:43
  3. Forward declarations needed for some?
    By doktorn in forum Newbie
    Replies: 6
    Last Post: 28th November 2007, 08:56
  4. Why forward declaration ?
    By probine in forum General Programming
    Replies: 3
    Last Post: 26th January 2007, 18:22
  5. QTextBrowser::forward() and backward()
    By derrickbj in forum Qt Programming
    Replies: 4
    Last Post: 13th October 2006, 21:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.