PDA

View Full Version : Mainwindow qprocesss



zorro68
29th November 2007, 10:05
I have to run an external aplication (in windows an exe file) from a qt aplication. With this code works correctly, but when i change to other aplication and the external app is running, qt app is all white(no controls, no boxes....) and when the external app finished, qt show all widget correctly.



QString fullinputName=TXTDatosArchivo->text();

QStringList Parameters;
Parameters<<fullinputName;
QString strprocess="GDAM.exe";
QProcess *myProcess=new QProcess(this);
myProcess->waitForFinished();
QApplication::setOverrideCursor(Qt::WaitCursor);

int salida = myProcess->execute(strprocess,Parameters);
if (salida!=0){
QMessageBox::critical(this,"Error",lang->leer_idioma("148").arg(strprocess));
QApplication::restoreOverrideCursor();
........
}else{
..........}


Some help please!!!!!!!

jpn
29th November 2007, 10:11
First of all, QProcess::execute() is a static method. Secondly, as it says in the docs, QProcess::execute() "waits for the process to finish". Thirdly, do not use QProcess::waitFor*() methods in GUI applications because they block the event loop meanwhile the process is running. This is why the application has no chance to repaint itself. Use QProcess::start() and connect to appropriate signals to get notified when something interesting happens.

zorro68
29th November 2007, 10:39
Do you know an example on how to use signals in qprocess (finished(), exitCode, exitStatus, error,...)?

Thanks for quick reply

jpn
29th November 2007, 10:45
Do you know an example on how to use signals in qprocess (finished(), exitCode, exitStatus, error,...)?
Use the powerful search facilities of the forum! Here's one: http://www.qtcentre.org/forum/p-i-start-a-external-fortram-program-how-to-terminate-post52424/postcount2.html

zorro68
29th November 2007, 13:14
I'm trying and reading and the information have been too usefull for me.

Thanks