c++qprocessqt6deprecation-warning

How to pass a multiple arguments command as a single string to QProcess?


Before, I did:

Qprocess* dlvid = new QProcess;
//command to start
QString ffmpegmerge = "ffmpeg -i myvid.mp4 -i myaudio.m4a -c copy -movflags faststart mergevid";
//starting the process
dlvideo->start(ffmpegmerge);

and it works well with a clazy warning about deprecated QProcess::start.

With the deprecated dlvideo->start(ffmpegmerge) now I do (I think I follow the qt.doc for the new QProces::start method)

dlvideo->start("ffmpeg", QStringList() << "-i" << "myvid.mp4" << QStringList() << "-i" << "myaudio.m4a" << QStringList() << "-c" << "copy" << QStringList() << "-movflags" << "faststart" << mergevid);

and it works well without clazy warning.

In my program myvid, myaudio, mergevid are some QString that are define before but it is not the object of this question.

I want to know if I can concatenate all arguments in a single QString to start something like

dlvideo->start("ffmpeg", QString() << "Here I want all arguments in one shot" << mergevid;

Solution

  • It seems you just want a way to pass a command as it is to QProcess, as long as it does not generate a warning.

    You could use QProcess::startCommand just like you're using start():

    process.startCommand("ffmpeg -i myvid.mp4 -i myaudio.m4a -c copy -movflags faststart mergevid");
    

    It does not generate a deprecation warning, because it was introduced in Qt6.