error C2668: “QThread::start”: 对重载函数的调用不明确
#include <iostream>
#include <QThread>
#include <QString>
class MyThread : public QThread
{
Q_OBJECT
public:
MyThread(QString name = "") {
stopped = false;
this->name = name;
}
void run() {
while (!stopped) {
std::cout << "In " << name.toStdString() << "'s run()." << std::endl;
QThread::msleep(400);
}
}
void stop() {
stopped = true;
}
private:
volatile bool stopped;
QString name;
};
int main()
{
MyThread thread;
MyThread thread1("Thread1");
MyThread thread2("Thread2");
//
thread.start();
thread1.start();
thread2.start();
return 0;
}