After adding Q_OBJECT , getting compile error
-
Hello, here is my header file of a very simple class.
#ifndef MYTHREAD_H
#define MYTHREAD_H#include <QObject>
#include <QThread>class MyThread : public QThread
{Q_OBJECT
public:
MyThread();
void run();signals:
void sending();
};#endif // MYTHREAD_H
I have corresponding CPP file. When I compile this project I am getting below error.
g++ -m64 -o TestThread4 main.o mainwindow.o mythread.o moc_mainwindow.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
mythread.o: In functionMyThread::MyThread()': /home/aminul/build-TestThread4-Qt_4_8_7_in_PATH_qt5-**Debug/../TestThread4/mythread.cpp:4: undefined reference to
vtable for MyThread'
Makefile:107: recipe for target 'TestThread4' failed**This file comiles fine, if I remove "Q_OBJECT" the project complies fine.
What is the reason of this?
-
Hello, here is my header file of a very simple class.
#ifndef MYTHREAD_H
#define MYTHREAD_H#include <QObject>
#include <QThread>class MyThread : public QThread
{Q_OBJECT
public:
MyThread();
void run();signals:
void sending();
};#endif // MYTHREAD_H
I have corresponding CPP file. When I compile this project I am getting below error.
g++ -m64 -o TestThread4 main.o mainwindow.o mythread.o moc_mainwindow.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
mythread.o: In functionMyThread::MyThread()': /home/aminul/build-TestThread4-Qt_4_8_7_in_PATH_qt5-**Debug/../TestThread4/mythread.cpp:4: undefined reference to
vtable for MyThread'
Makefile:107: recipe for target 'TestThread4' failed**This file comiles fine, if I remove "Q_OBJECT" the project complies fine.
What is the reason of this?