新建了一个简单地线程:
class Threada: public QThread
{
//Q_OBJECT
private:
volatile bool stopped;
protected :
void run();
void stop();
signals:
};
void Threada::run()
{
//QProcess::execute("E:\\QT_PRJ\\mine\\build-test1-Desktop_Qt_5_2_1_MinGW_32bit-Debug\\debug\\test1.exe",QStringList());
QProcess::execute("E:\\MFC_PRJ\\chromatool_modify_0916\\chromatool\\Debug\\test.exe",QStringList());
//qDebug()<<"zhengchang";
//flag=1;
exec();
}
在调用线程时,出现错误:
QThread: Destroyed while thread is still running
QMutex: destroying locked mutex
解决:
将放在槽函数中的私有对象添加在:(Threada thread1)
(不知道是什么原因,先标记一下)
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
Threada thread1;
}