Results 1 to 3 of 3

Thread: QProcess issue with single quote ' on argument (win)

  1. #1
    Join Date
    Jun 2013
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QProcess issue with single quote ' on argument (win)

    Hi,

    I having a weird issue using QProcess. I have two Qt (4.8.4) apps, the firts one starts detached the second one, passing a filePath as argument.

    Invocation from app1:
    Qt Code:
    1. QProcess::startDetached("app2Path/app2",QStringList() << filePath);
    To copy to clipboard, switch view to plain text mode 

    Getting the argument in app2
    Qt Code:
    1. QString filePath= QCoreApplication::arguments().at(1);
    To copy to clipboard, switch view to plain text mode 

    if filePath contains a single quote ', the quote doesn't appears in filePath app2. Example:

    Qt Code:
    1. QProcess::startDetached("app2Path/app2",QStringList() << "c:/temp/1'1.file");
    2. ...
    3. QString filePath= QCoreApplication::arguments().at(1);
    4.  
    5. filePath is: "c:/temp/11.file"
    To copy to clipboard, switch view to plain text mode 

    Launching app2 from command line, only works fine if I use double quotes in the argument:

    app2 c:\temp\1'1.file --> don't work
    app2 "c:\temp\1'1.file" --> OK

    What is going on? I haven't test this issue in MacOSX or Linux.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QProcess issue with single quote ' on argument (win)

    Then start with double quoted arguments
    Qt Code:
    1. QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"")
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jun 2013
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess issue with single quote ' on argument (win)

    Thank you, I totally missed this approach

    BTW, this is not working (app2 doesn't start):
    Qt Code:
    1. QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"")
    To copy to clipboard, switch view to plain text mode 
    I have fixed it, doing this:
    Qt Code:
    1. QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"",QStringList())
    To copy to clipboard, switch view to plain text mode 
    Last edited by louissmr; 15th July 2013 at 21:08.

Similar Threads

  1. special characters as argument of QProcess
    By dotjan in forum Newbie
    Replies: 1
    Last Post: 19th March 2012, 03:15
  2. QProcess issue with GPG under Windows
    By superpacko in forum Qt Programming
    Replies: 6
    Last Post: 7th September 2011, 20:19
  3. quote in command promps
    By QuAzI in forum Newbie
    Replies: 8
    Last Post: 15th December 2010, 21:28
  4. QProcess issue
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 21st December 2009, 07:40
  5. Replies: 1
    Last Post: 18th May 2009, 09:49

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.