PDA

View Full Version : multiple qprocess arguments



czilla
28th January 2015, 10:02
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"?


#include <QtGui>
#include <QApplication>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);

QProcess sox; //instantiate the process****
QStringList args1; //declare arguments
args1 << "infile.wav"; //collect arguments to be envoked with qprocess
args1 << "-c 1"; //collect arguments to be envoked with qprocess
args1 << "outfile.wav"; //collect arguments to be envoked with qprocess
//args1 << "remix 0 1"; //collect arguments to be envoked with qprocess

sox.start("sox", args1); //pass qprocess and arguments to start method
QByteArray output; //understood by QString
while(sox.waitForReadyRead())
output += sox.readAll();
qDebug() << "sox" << args1;
}

Lesiok
28th January 2015, 10:05
What it is "it gives an error" ? What error ?

anda_skoa
28th January 2015, 10:26
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



QStringList args1;
args1 << "infile.wav";
args1 << "-c";
args1 << "1";
args1 << "outfile.wav";
args1 << "remix";
args1 << "0";
args1 << "1";

or


QStringList args1;
args1 << "infile.wav" << "-c" << "1" << "outfile.wav" << "remixe" << "0" << "1";


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

Cheers,
_

czilla
28th January 2015, 10:30
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

Lesiok
28th January 2015, 11:09
As anda_skoa said : You have 7 args not 3.