QProcess: invalid arguments
Solved
General and Desktop
-
Hi All,
I'm working on a rasperry pi running rasperian, with Qt Creator 4.2.0 based on Qt 5.7.1
I'm trying to start the external process "raspivid -o file.h264". I've written the following code snippet:void ExternalCamera::slotStartCapture(QString filename) { QStringList arguments; arguments <<"-o file.h264"; myProcess->setArguments(arguments); myProcess->setProgram("/usr/bin/raspivid"); myProcess->start(); myProcess->waitForFinished(20000); qDebug()<<myProcess->exitCode(); qDebug()<<myProcess->errorString(); }
Then I see this in the applications output window:
"Invalid command line option (-o file.h264)\n" 64 "Unknown error"
What am I doing wrong?
Cheers,
Cedric -
Hi
can you try
arguments <<"-o" << "file.h264"; -
Hi,
As @mrjj as well as QProcess's documentation, each element of the options should be put in the argument list separately.
-
@mrjj said in QProcess: invalid arguments:
arguments <<"-o" << "file.h264";
It works, Thank you. For future reference:
void ExternalCamera::slotStartCapture(QString filename) { QStringList arguments; arguments <<"-o" << "file.h264"; //arguments <<"-o file.h264"; myProcess->setArguments(arguments); myProcess->setProgram("/usr/bin/raspivid"); myProcess->start(); myProcess->waitForFinished(20000); qDebug()<<myProcess->exitCode(); qDebug()<<myProcess->errorString(); }
console output:
0 "Unknown error"