尽管定义了除信号之外的所有其他功能,但在Qt中未定义对vtable的引用?

我知道此错误通常是由于父类具有虚函数而未在子类中定义虚函数而发生的。

据我所知,至少定义了所有功能来禁止应该作为信号的功能。

这是该类的.h文件


#ifndef HREAD_H
#define HREAD_H
#include "package.h"
#include <QThread>
class hread:public QThread
{
    Q_OBJECT
signals:
    void transfer(structureData* pkg);
public:
    hread();
   virtual ~hread();

private:
    structureData pkgSend;
    QMutex MutexSend;
    bool abort,restart;
protected:
    void run() override;
};

#endif // INPUTTHREAD_H

这是我的主要.cpp文件

hread::hread()
{
 MutexSend.lock();
 restart=false;
 abort=false;
 MutexSend.unlock();
}

hread::~hread()
{

}

void hread::run()
{

    emit transfer(&pkg);

}

我不太清楚为什么会出现此错误。

g++  -o lab20 main.o window.o recvvwindow.o outputthread.o inputthread.o moc_window.o moc_recieverWindow.o moc_outputthread.o   -L/usr/local/lib -lwiringPi -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread 
inputthread.o: In function `InputThread::InputThread()':
/home/pi/Documents/ELEC1204/build-lab20-Desktop-Debug/../P20/inputthread.cpp:9: undefined reference to `vtable for InputThread'
inputthread.o: In function `InputThread::~InputThread()':
/home/pi/Documents/ELEC1204/build-lab20-Desktop-Debug/../P20/inputthread.cpp:14: undefined reference to `vtable for InputThread'
inputthread.o: In function `InputThread::run()':
/home/pi/Documents/ELEC1204/build-lab20-Desktop-Debug/../P20/inputthread.cpp:37: undefined reference to `InputThread::transferPackageToRecieve(dataPackage*)'
collect2: error: ld returned 1 exit status
make: *** [lab20] Error 1
Makefile:145: recipe for target 'lab20' failed
22:13:53: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project lab20 (kit: Desktop)
When executing step "Make"
评论