1

I am using Qt. Can anyone tell me how to use string inside QProcess? To be more clear I am making a image convertor in which I take target file path of png file to a string using QFileDialog. Now I have a exe file which does all conversion of png to jpeg and I need to do somehing like this:

convertor.exe  path/to/png/file  path/for/storing/converted/output

How I can do this in Qt?

QProcess conv;
conv.start("C:/converter.exe" ??) what to do here?

2 Answers 2

3

You can give the arguments to the process as a QStringList:

QStringList args;
args << "path/to/png/file" << "path/for/storing/converted/output";
QProcess conv;
conv.start("C:/converter.exe", args);
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you I will try this :D Cannot vote up as I have reputation<15 :D
Varun Chitre: You can accept the answer though if it helped you.
Instead of QStringList args can we use QString args?
Yes. See documentation. But I have usually found it more convenient and less error prone to use QStringList. For example, if your paths can contain spaces, it is much easiers to use the QStringList version.
1

Arguments to QProcess are passed in a QStringList: http://doc.qt.io/qt-4.8/qprocess.html#start

QStringList args;
args << pathToPng << pathToOutput
QProcess conv;
conv.start("c:/converter.exe", args);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.