C++ (Qt)class CProcessThread: public QThread{ Q_OBJECT QString m_appStr; QStringList m_listParam; QProcess * m_process; signals: void finished(int , enum QProcess::ExitStatus exitStatus, CProcessThread *); void error(enum QProcess::ProcessError, QString); public: CProcessThread(const QString& appStr, const QStringList& listParam); CProcessThread(); void setParams(const QString& appStr, const QStringList& listParams); void run(); ~CProcessThread(); public slots: void finish(); void errorFinish(); }; #include "CProcessThread.h" void CProcessThread::run(){ if(m_process == NULL) m_process= new QProcess(); connect(m_process,SIGNAL(finished(int , enum QProcess::ExitStatus)), this, SLOT(finish())); connect(m_process,SIGNAL(error(enum QProcess::ProcessError)), this, SLOT(errorFinish())); qDebug()<<"//---------------------------//\n"<<QString("start %1 Thread").arg(m_appStr)<<m_listParam; m_process->start(m_appStr, m_listParam); exec(); } void CProcessThread::setParams( const QString& appStr, const QStringList& listParams ){ m_appStr = appStr; m_listParam = listParams;} CProcessThread::CProcessThread( const QString& appStr, const QStringList& listParam ){ setParams(appStr,listParam); m_process = NULL; } CProcessThread::CProcessThread(){ m_process =NULL; } CProcessThread::~CProcessThread(){ qDebug()<<QString("delete %1 Thread").arg(m_appStr); delete m_process; m_process = NULL;} void CProcessThread::finish(){ qDebug()<<QString("finish %1 Thread").arg(m_appStr)<<m_process->exitCode()<<m_process->exitStatus()<< m_process->errorString()<<m_process->error(); emit finished(m_process->exitCode(), m_process->exitStatus(), this);} void CProcessThread::errorFinish(){ emit error(m_process->error(), m_process->errorString()); finish();}