Results 1 to 14 of 14

Thread: Problem with file paths in XP

  1. #1
    Join Date
    Sep 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with file paths in XP

    Hi,

    I'm using QFileDialog to get file paths in my program. These paths are valid in Windows 7. But when I use the same code for Windows XP, there is an error interpreting the file paths correctly (specified file not found). This happen when there are spaces in the path (e.g.: C:\Documents and Settings\...)

    How can overcome this problem?

    Thanks,
    Indika...

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with file paths in XP

    Can you show some code as to how are you using the path returned from QFileDialog?

  3. #3
    Join Date
    Sep 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with file paths in XP

    Qt Code:
    1. _OutputFolder = QFileDialog::getExistingDirectory(0, ("Select Output Folder"), QDir::currentPath());
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with file paths in XP

    i asked, how are you using _OutputFolder later in your code where the error comes.

  5. #5
    Join Date
    Sep 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with file paths in XP

    Qt Code:
    1. args << _OutputFolder;
    2.  
    3. process = new QProcess(this);
    4. process2 = new QProcess(this);
    5.  
    6. process->start("./Generator.exe", args); //this works fine
    7. process2->start("explorer.exe", args); //this won't open the destination folder in XP since it can't identify the path (probably with spaces)
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with file paths in XP

    add "(quotes) to your file path.

    Qt Code:
    1. _OutputFolder = "\"" + _OutputFolder + "\"";
    To copy to clipboard, switch view to plain text mode 

    EDIT:
    But it should have worked without quotes, because in QProcess docs its written that the quotes are automatically added. Does explorer.exe opens?

  7. #7
    Join Date
    Sep 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with file paths in XP

    No it does not open the explorer. See the screenshot below with the code I gave you.
    image001.png

    I found that all '\' is printed as '/' in the error message.


    Added after 1 2 minutes:


    How to get this done? please help.
    Last edited by IndikaU; 13th October 2011 at 12:58.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with file paths in XP

    QFileDialog returns a path which is correct to use within Qt. It can't guarantee that if you use it directly in a call to an external application, the application will be able to handle it. If you just want to use explorer on the path provided then use QDesktopServices::openUrl() passing in the result of QUrl::fromLocalFile(). In a general situation you'd need to prepare the path manually so that the external app understands it (it is supprising though that explorer can't handle forward-slashed file paths, I thought XP handled that ok).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Problem with file paths in XP

    The question I'd have is what is QFileDialog actually returning under each of the OS'...

    In Python I would edit in Idle and "print" the value in question.

    In VB-6 I'd use Debug.Print and have the Debug window up.

    If all else fails print it to your Window Title.

    So far, knock... knock... knock... I have not had a file path issue between WinXP and Win7 using VB-6. But, VB-6 "baby's" the programmer.

    A problem does exist when using C:\Program Files\Some.exe from a command window, in this case XP requires the entire pathname to be in quotes.

    If your language is passing this, using some form of a command mode, then XP will only see the pathname to the first space.

    You could even experiment by creating a test Folder/Directory (in both OS') that has no spaces in it and see if it works.

    If it does, then that "probably" indicates, that, for whatever reason, XP isn't seeing the whole pathname because of embedded spaces.

    My only hope in rambling so, it that it sparks a useful thought from those that *really* know what they are doing.

    Mike Sr.

    As I said, my first step would be to see what is actually being returned in each OS and then, if need be use a switch to modify the value based on which OS you are in.

    DOES ANYONE KNOW HOW TO KEEP THESE ENTRY AREAS FROM AUTO-SCROLLING BACK TO THE TOP????

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with file paths in XP

    In Qt there is qDebug() you can use for debugging.

    By the way, I don't experience any auto-scrolling
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Problem with file paths in XP

    I am on a Locked down work machine that is still using IE7...

    It may be an IE issue because IE9 at home does the same thing...

    Seems to happen during Auto Save, and periods of inactivity.

    What browser are you using?

    Mike Sr.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with file paths in XP

    We're getting offtopic here. If you want to discuss functionality of the site, please post in the Feedback forum (when you're allowed to).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Sep 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with file paths in XP

    Hi,

    With all comments I think that the actual problem was Windows XP explorer would not handle paths with '/'. So this may be problem when coding for both XP and 7.

    How to detect the OS to replace '/' with '\'?

    Note: Same code works fine with Windows 7 since it can handle '/';

    Indika...

  14. #14
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with file paths in XP

    QDir::toNativeSeparators


Similar Threads

  1. Relative paths in Qt
    By drmath in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 16:50
  2. X11 include and lib paths
    By Oluwafemi in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd April 2010, 15:25
  3. Replies: 7
    Last Post: 10th September 2009, 21:21
  4. include paths
    By altec in forum Installation and Deployment
    Replies: 0
    Last Post: 8th August 2008, 11:59
  5. How to set paths?
    By hoborg in forum Installation and Deployment
    Replies: 11
    Last Post: 24th February 2006, 19:08

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.