Results 1 to 5 of 5

Thread: multiple qprocess arguments

  1. #1
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default multiple qprocess arguments

    I am invoking a linux system process using QProcess. The process works, but when I supply more arguments than the three prescribed arguments it gives an error.

    sox.start("sox", infile.wav -c 1 outfile.wav remix 0 1);

    How can I make it accept my last argument "remix 0 1"?
    Qt Code:
    1. #include <QtGui>
    2. #include <QApplication>
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QProcess sox; //instantiate the process****
    9. QStringList args1; //declare arguments
    10. args1 << "infile.wav"; //collect arguments to be envoked with qprocess
    11. args1 << "-c 1"; //collect arguments to be envoked with qprocess
    12. args1 << "outfile.wav"; //collect arguments to be envoked with qprocess
    13. //args1 << "remix 0 1"; //collect arguments to be envoked with qprocess
    14.  
    15. sox.start("sox", args1); //pass qprocess and arguments to start method
    16. QByteArray output; //understood by QString
    17. while(sox.waitForReadyRead())
    18. output += sox.readAll();
    19. qDebug() << "sox" << args1;
    20. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 28th January 2015 at 09:22. Reason: missing [code] tags

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: multiple qprocess arguments

    What it is "it gives an error" ? What error ?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: multiple qprocess arguments

    Are you sure that "remix 0 1" is a single argument?
    Would you pass that quoted on the shell?

    My guess is that these are actually three arguments

    Qt Code:
    1. args1 << "infile.wav";
    2. args1 << "-c";
    3. args1 << "1";
    4. args1 << "outfile.wav";
    5. args1 << "remix";
    6. args1 << "0";
    7. args1 << "1";
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. args1 << "infile.wav" << "-c" << "1" << "outfile.wav" << "remixe" << "0" << "1";
    To copy to clipboard, switch view to plain text mode 

    Rule of thumb: any space on the commandline starts a new argument, unless it is escaped or quoted.

    Cheers,
    _

  4. #4
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: multiple qprocess arguments

    apologies for not posting correctly.

    When the system process is called by QProcess it does not produce any result, however when it is entered on a terminal it works. Here is the complete command:

    sox infile.wav -c 1 outfile.wav remix 0 1

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: multiple qprocess arguments

    As anda_skoa said : You have 7 args not 3.

Similar Threads

  1. Replies: 7
    Last Post: 15th November 2010, 09:00
  2. QProcess Arguments
    By doggrant in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2010, 16:45
  3. QProcess error Using Arguments Qt 4.5
    By xanders in forum Qt Programming
    Replies: 6
    Last Post: 15th May 2009, 15:56
  4. Replies: 3
    Last Post: 25th February 2009, 16:55
  5. QProcess and none-string arguments
    By Raistlin in forum Qt Programming
    Replies: 8
    Last Post: 12th March 2008, 15:28

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.