C++ (Qt)// Local#include "Object.h" // Qt#include <QCoreApplication>#include <QTimer> int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); Object obj; QTimer::singleShot(0, &obj, SLOT(startProcess())); return a.exec();}
C++ (Qt)#ifndef OBJECT_H#define OBJECT_H // Qt#include <QObject>#include <QProcess> class Object : public QObject{ Q_OBJECT public: Object(QObject* parent = 0); public slots: void startProcess(); void on_process_finished(int exitCode, QProcess::ExitStatus exitStatus); private: QProcess* process;}; #endif // OBJECT_H
C++ (Qt)// Local#include "Object.h" // Qt#include <QDebug> Object::Object(QObject* parent) : QObject(parent), process(new QProcess(this)){ process->setObjectName("process"); QMetaObject::connectSlotsByName(this);} void Object::startProcess(){ process->start("ls -l");} void Object::on_process_finished(int exitCode, QProcess::ExitStatus exitStatus){ qDebug() << exitCode << exitStatus;}
C++ (Qt)CProcessThread::CProcessThread( const QString& appStr, const QStringList& listParam ){ setParams(appStr,listParam); m_process = NULL;} CProcessThread::CProcessThread(){m_process =NULL;}