Results 1 to 2 of 2

Thread: Quoting problem with QProcess

  1. #1
    Join Date
    Sep 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Unhappy Quoting problem with QProcess

    Hi,
    I need help for using QProcess.
    I have to run a cmd like this:

    Qt Code:
    1. cmd -param1 -param2 value2 -param3 value3:title="My Title with spaces"
    To copy to clipboard, switch view to plain text mode 

    For param1 & param2 no problems; param3 dont'work.

    My code is:

    Qt Code:
    1. [...]
    2. #include <qprocess.h>
    3.  
    4. int main (int argc, char **argv)
    5. {
    6.  
    7. [...]
    8.  
    9. QApplication a (argc, argv);
    10. QProcess *proc;
    11.  
    12. [...]
    13.  
    14. proc = new QProcess ();
    15. proc->addArgument ("cmd");
    16. proc->addArgument ("-param1");
    17. proc->addArgument ("-param2");
    18. proc->addArgument ("value2");
    19. proc->addArgument ("-param3");
    20. QString myCmd = "value3:title=\"My Title with spaces\"";
    21. proc->addArgument (myCmd);
    22.  
    23. if (!proc->start())
    24. {
    25. // error handling
    26. exit (-1);
    27. }
    28.  
    29. return 0;
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 

    When I launch this program I have no error but the third parameter is not correct. This arrives quoted. I think I have to avoid quoting...
    I'm using Linux with bash shell.

    Thanks for any help,
    the_bis

  2. #2
    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: Quoting problem with QProcess

    Well, if you quote it then it arrives quoted... When using bash (or other shell) you use quotes when you wish to inform the shell that a particular block of text is really a single element although it contains spaces or other special characters. QProcess doesn't use the shell, it invokes the command directly, so quoting is not needed. Try passing simply "value3:title=My Title with spaces" as the third argument.

Similar Threads

  1. problem with QProcess in Qt4
    By kennyxing in forum Qt Programming
    Replies: 4
    Last Post: 20th October 2006, 09:07
  2. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30
  3. QProcess problem in accessing stdout
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 17:56
  4. Qt4 QProcess Problem
    By qleutes in forum Qt Programming
    Replies: 10
    Last Post: 23rd January 2006, 09:42
  5. QProcess problem with windows batch file
    By bood in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 08: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.