PDA

View Full Version : Pass a QString as args for commandProcess



mikemakus
3rd December 2009, 17:12
Hi,

I'm totally new to Qt, and I'm trying to create a simple frontend for the "mencoder" video encoder using Qt Creator.

So, I use commandProcess to call "mencoder" and pass some parameters :



QStringList args;
args << "-ovc";
args << "help";
commandProcess.start("mencoder", args);


It works fine. Now what I don't understand is how to make this work :



QStringList args;
args << ui->lineEditInput->text();
commandProcess.start("mplayer", args);


As you can see in the code, I want that a user typed string of parameters entered into a lineEdit will be passed as args for commandProcess.

Any leads ?

Lesiok
3rd December 2009, 17:52
You must divide lineEditInput->text() into individual tokens because without that mencoder receives one argument. I.e. if user type "-ovc blabla bleble" You must send to mencoder 3 parameters : 1.-ovc 2.blabla 3.bleble. Now You are sending them one parameter "-ovc blabla bleble". This is not the same.

Tanuki-no Torigava
3rd December 2009, 23:03
You can convert your args through QStringList and then submit the args using QString.to* methods. See assistant for details.