这是我的标题:
#ifndef BARELYSOCKET_H
#define BARELYSOCKET_H
#include <QObject>
//! The First Draw of the BarelySocket!
class BarelySocket: public QObject
{
Q_OBJECT
public:
BarelySocket();
public slots:
void sendMessage(Message aMessage);
signals:
void reciveMessage(Message aMessage);
private:
// QVector<Message> reciveMessages;
};
#endif // BARELYSOCKET_H
这是我的课:
#include <QTGui>
#include <QObject>
#include "type.h"
#include "client.h"
#include "server.h"
#include "barelysocket.h"
BarelySocket::BarelySocket()
{
//this->reciveMessages.clear();
qDebug("BarelySocket::BarelySocket()");
}
void BarelySocket::sendMessage(Message aMessage)
{
}
void BarelySocket::reciveMessage(Message aMessage)
{
}
我收到链接器错误:
undefined reference to 'vtable for BarelySocket'
Message
是一个复杂的 struct
,但即使使用 int
不解决问题.
Message
is a complex struct
, but even using int
instead did
not fix things.任何时候添加对 Q_OBJECT 宏的新调用,都需要再次运行 qmake.您所指的 vtables 问题与此直接相关.
Any time you add a new call to the Q_OBJECT macro, you need to run qmake again. The vtables issue you're referring to is directly related to that.
只要运行 qmake,假设您的代码中没有其他问题,您应该会很高兴.
Just run qmake and you should be good to go assuming there are no other issues in your code.
这篇关于Qt 链接器错误:“对 vtable 的未定义引用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!