PDA

View Full Version : Starting QProcess from QThread



sandeep.theartist
5th June 2012, 06:28
I was using QThreads in Qt where my need is to launch a command-line executable from within a Qt thread and run the same within the thread's context. I have used the below mentioned code for the same which seems to be running fine. However, I wanted to know if this kind of usage is permitted since we are launching a QProcess from within a QThread.


void Help_Menu_Thread::run()
{
Insert_Log("INFO::Help file referred by Admin");
QProcess HelpStart;
HelpStart.execute("c:\\windows\\hh.exe LPRS_help.chm");
HelpStart.close();
}

Awaiting your response.

Regards,
Sandeep

chenz
5th June 2012, 07:22
I would just use QProcess::startDetached and not use a thread at all for this kind of stuff.

sonulohani
7th June 2012, 06:18
Since, Thread is a lightweight and process is the heavyweight, So it is unnecessary to define a heavyweight process under lightweight. I am not confirmed about that, but that what my perception says....