Hey I am trying to do this basic program with Qthread. I have linking error and dont know how to resolve it. Inside the main method I call operate and it gives me this error:
main.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall Controller::operate(void)" (?operate@Controller@@QAEXXZ)" in Funktion "_main".
#include <QCoreApplication>
#include <QThread>
#include <QDebug>
class Worker : public QObject
{
Q_OBJECT
public slots:
void doWork() {
QString result;
for(int i= 0; i<10;i++){
qDebug() << i <<endl;
this->thread()->sleep(2);
}
emit resultReady(result);
}
signals:
void resultReady(const QString &result);
};
class Controller : public QObject
{
Q_OBJECT
QThread workerThread;
public:
Controller() {
Worker *worker = new Worker;
worker->moveToThread(&workerThread);
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
connect(this, &Controller::operate, worker, &Worker::doWork);
connect(worker, &Worker::resultReady, this, &Controller::handleResults);
workerThread.start();
}
~Controller() {
workerThread.quit();
workerThread.wait();
}
public slots:
void handleResults(const QString &);
signals:
void operate();
void display(){
qDebug() << "DISPLAYING";
};
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Controller *c;
c->operate();
for(int i= 0; i<10;i++){
c->display();
a.thread()->sleep(1);
}
return a.exec();
}
Do you have any idea what it could be?