PDA

View Full Version : running external console program by gui program



alireza.mixedreality
24th April 2010, 17:48
hi
im gonna run a console program by gui program!
i know that i should use Qprocess but when i use this command in my mainwindow constructor only console program is running and my gui doesent until i close console program!

what should i do?
is there any mainwindow load event?
thanks!

Lykurg
24th April 2010, 18:06
Show us how you use QProcess in your ctor. There you probably doing something wrong.

alireza.mixedreality
24th April 2010, 18:20
at the end of constructor:

QString run="./OperatorServer";
Qprocess *executable = new QProcess(this);
executable->execute(run);

Lykurg
24th April 2010, 18:29
I knew it;) execute blocks your main thread, therefore the GUI never pop up. Use QProcess::start() instead (note: it is asynchronous) and use proper connections to interact with your shell program.

borisbn
24th April 2010, 19:05
Try QProcess::startDetached