我先从QThread继承一个类,重载run()函数:
class MyThread : public QThread
{
Q_OBJECT
public:
void run();
void stop();
private:
QProcess *MyProcess;
};
MyThread::MyThread(QWidget *parent )
{
MyProcess = new QProcess(parent);
}
void MyThread::run()
{
MyProcess->execute("ComputerFortran"); //调用Fortran计算程序
}
void MyThread::stop()
{
MyProcess->kill();
MyProcess->terminate();
}
在使用的时候定义了一个MyThread类型的成员变量,启动外部应用程序时调用其start()方法:
Quote:
class ...............
{...........
MyThread thread;
............
};
.....................
thread.start();
但是调用thread.stop()时并没有将外部的Fortran应用程序终止??