线程、进程

1、线程

QThread* thread = new QThread;

MyThread* mythread = new MyThread;   // 继承于QObject的类
mythread->movetoThread(thread);
connect(thread, SIGNAL(started()), mythread, SLOT(run()/*子线程中运行*/));
connect(thread, SIGNAL(deletelater()), this, SLOT());

2、进程

QProcess p;
p.start(exeFile, arguments);
or
p.start(cmd)
or
p.startDetached(exeFile, arguments);
// Start 随着主程序退出而退出
// StartDetached 不随着主程序退出而退出
p.waitForFinished();

Table of Contents