I tried to use QThread
for my first time and I want to emit signal from non-member static function.
My DataReceiver.h
file:
#ifndef DATARECEIVER_H
#define DATARECEIVER_H
#include <QObject>
#include "vrpn_Analog.h"
class DataReceiver : public QObject {
Q_OBJECT
public:
DataReceiver();
public slots:
void check();
signals:
void blink();
};
void VRPN_CALLBACK handle_analog( void* userData, const vrpn_ANALOGCB a );
#endif // DATARECEIVER_H
My DataReceiver.cpp
file:
#include "datareceiver.h"
#include "vrpn_Analog.h"
DataReceiver::DataReceiver()
{
}
void DataReceiver::check()
{
bool running = true;
/* VRPN Analog object */
vrpn_Analog_Remote* VRPNAnalog;
/* Binding of the VRPN Analog to a callback */
VRPNAnalog = new vrpn_Analog_Remote("openvibe_vrpn_analog@localhost");
VRPNAnalog->register_change_handler(NULL, handle_analog);
/* The main loop of the program, each VRPN object must be called in order to process data */
while (running)
{
VRPNAnalog->mainloop();
}
}
void VRPN_CALLBACK handle_analog( void* userData, const vrpn_ANALOGCB a )
{
for( int i=0; i < a.num_channel; i++ )
{
if (a.channel[i] > 0)
{
emit blink();
}
}
}
In handle_analog
I try to emit signal, which I want to use in another class.
void MainWindow::checkChannels()
{
QThread *thread = new QThread;
DataReceiver *dataReceiver = new DataReceiver();
dataReceiver->moveToThread(thread);
//connect(thread, SIGNAL(blink()), this, SLOT(nextImage()));
thread->start();
}
but when I try to run I get error:
error: C2352: 'DataReceiver::blink' : illegal call of non-static member function
I know, where my mistake is, but I don't know, how to fix it.