Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QProcess: invalid arguments



  • 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


  • Lifetime Qt Champion

    Hi
    can you try
    arguments <<"-o" << "file.h264";


  • Lifetime Qt Champion

    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"
    


  • @cdwijs it looks your issue is solved. If so, please don't forget to mark your post as such. Thanks.


Log in to reply