You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
911 B

#ifndef THREADBINDER_H
#define THREADBINDER_H
#include <QThread>
#include "model/ultrasoundModule/UsModule.h"
#include "model/csm/utils/MouseEventFilter.h"
class ThreadBinder : public QObject
{
public:
static void bind(UsModule* obj, bool eventFilter)
{
auto thread = new QThread();
obj->moveToThread(thread);
if(eventFilter)
{
auto mousEv = new TrackballMouseEventFilter();
mousEv->moveToThread(thread);
obj->installEventFilter(mousEv);
}
//TODO: say this to logger connect(obj, SIGNAL (error(QString)), this, SLOT
//(errorString(QString)));
connect(thread, SIGNAL(started()), obj, SLOT(threadStarted()));
connect(obj, SIGNAL(finished()), thread, SLOT(quit()));
connect(obj, SIGNAL(finished()), obj, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
};
#endif //THREADBINDER_H