[Qt-interest] QProcess on windows and the dirty work of quotes...

Gilberto Cuba Ricardo gilbert at hlg.rimed.cu
Tue Apr 20 21:46:13 CEST 2010


Hi,

  I'm trying to run a Windows process with QProcess class and I
  encountered with several difficulties. The first one is when I try
  to terminate a process that have a child process; because QProcess
  don't close all process tree. The second one, -and this really
  affect to me so much- is with the quotes and spaces on programs
  parameters. For example:

  QProcess *processApp = new QProcess(this);
  ...
  QString qsAppName = "<absoulte path with spaces>/mysqld-nt.exe";
  QStringList qslAppParams;

    // this not a problem...
  qslAppParams << "--standard_param";
    // ok... I understands that I not need to put a quotes... it's make
    // a dirty work, but...
  qslAppParams << "\"param_with_explicits_quotes\"";
    // here is my big problem...
  qslAppParams << "--params=<absoulte path with spaces>/filename.any"
  ...
  processApp->start( qsAppName, qslAppParams );
  processApp->waitForStarted(1000);

  Why the third params is a problem? Because if I put a quotes after
  equal sign and at the end line, 'QProcess' insert before the quotes,
  one backslash (\), and if I don't put nothing (quotes) it
  ('QProcess') put a quotes at the first and at the end of argument
  line, and these changes are incorrect. I don't know do that!

  I really don't understands why QProcess make this functionality.
  I look in the source code 'src/corelib/io/qprocess_win.cpp' on
  function 'qt_create_commandline()' and I confuse with the two first
  QString replaces of loop 'for', but I consider that this is not a
  better work for help.

  Exist any form to pass a arguments parameters of program to a
  function start(...), that it ('QProcess') don't make any changes?

  I think that these difficulties not only affect to me and it's
  possible to include these features for a new version of Qt. If anyone
  is disagree with my opinion or somebody have a persuasive answer to my
  problems, I'm all ears.

-- 
Cheers,
 Lic. Gilberto Cuba Ricardo

 Sorry for my English. :)





More information about the Qt-interest-old mailing list