Заголовок:
#ifndef CONTROLLER_THREAD
#define CONTROLLER_THREAD
#include <QThread>
class Worker : public QObject
{
Q_OBJECT
public:
Worker();
~Worker();
private slots:
void calculateImage();
signals:
void imageReady();
};
class Controller: public QObject
{
public:
Worker objWorker;
QThread objQThread;
Controller();
~Controller();
public slots:
void receiveImage();
};
#endif // CONTROLLER_THREAD
Источник:
#include <controller_thread.h>
Worker::Worker(){}
Worker::~Worker(){}
void Worker::calculateImage()
{
}
Controller::Controller()
{
objWorker.moveToThread( &objQThread );
connect( objWorker, objWorker::imageReady, this, receiveImage );
objQThread.start();
}
Controller::~Controller(){}
void Controller::receiveImage()
{
}
Я получаю сообщение об ошибке:
error: ‘objWorker’ is not a class, namespace, or enumeration
connect( objWorker, objWorker::imageReady, this, receiveImage );
^
Что означает эта ошибка?Как решить?
Набрав это:
connect( objWorker, &Worker::imageReady, this, &Controller::receiveImage );
Результат:
error: no matching function for call to ‘Controller::connect(Worker&, void (Worker::*)(), Controller*, void (Controller::*)())