-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkerThread.h
More file actions
35 lines (29 loc) · 1.06 KB
/
Copy pathWorkerThread.h
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef WORKERTHREAD_H
#define WORKERTHREAD_H
#include <QThread>
#include "mainwindow.h"
#include "segmentation.h"
//derived class
class WorkerThread: public QThread { //public QThread makes WorkerThread a subclass of QThread
Q_OBJECT // macro that declares its own signals and slots or that uses Qts meta-object system
public:
//using QThread::QThread; //'using' allows us to adopt QThread as base constructor
WorkerThread(QObject *parent = nullptr) : QThread(parent), pixmap(nullptr) {}
~WorkerThread(){delete pixmap;}
void setData(QPixmap &p){
delete pixmap;
pixmap = new QPixmap(p);
}
private:
QPixmap *pixmap; //its a pointer because I want to be memory efficient
protected:
void run() override {
SegmentImg segImg;
QPixmap seg_pixmap = segImg.segmentImage(pixmap);
QString result = "Computation Complete.";
emit resultReady(seg_pixmap, result);
}
signals:
void resultReady(const QPixmap &seg_pixmap, const QString &result);
};
#endif // WORKERTHREAD_H