[Qt-interest] QProcess problem when argument has space in windows Qt 4.5
Rohan McGovern
rohan.mcgovern at nokia.com
Mon Mar 16 00:07:59 CET 2009
On Saturday 14 March 2009, ext Hari Panicker wrote:
> Hi all
>
> I am using Qt 4.5. I am trying start a msi install by calling
> msiexec.exe using QProcess. I am passing the path of the msi
> which has spaces in the path. I do put them between quotes. It
> just does not work... here is the code below
>
> int SetupWrapper::startProcess(QString args)
> {
> QString program = "msiexec.exe " + args;
> QProcess *myProcess = new QProcess(this);
> myProcess->start(program);
> myProcess->waitForFinished(-1);
> int errorcode=myProcess->exitCode();
> myProcess->close();
> return errorcode;
> }
>
>
Hi,
Try using the QProcess::start which takes a QStringList of
arguments. That takes the guesswork out of how to pass arguments.
Unrelated: in SetupWrapper::startProcess, create your QProcess on
the stack instead of the heap. There's no reason to use the heap
there.
--
Rohan McGovern
Qt Software, Nokia
More information about the Qt-interest-old
mailing list