问题描述
linux下qt开发
qt项目类继承了QObject,也添加了Q_OBJECT宏,显示“static assertion failed: No Q_OBJECT in the class with the signal”?
EDM.h文件部分代码
#include <QObject>
#include "common.h"
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <map>
#include <vector>
using namespace std;
enum
{
MSG\_PUMP\=1,
MSG\_ROTATE,
MSG\_STOP,
MSG\_RTZERO,
MSG\_PROTECT,
MSG\_TRANSFER,
MSG\_PRUNE,
MSG\_RTCENTER\_C,
MSG\_MAC\_PARA\_SET,
MSG\_AXIS\_ADJUST,
MSG\_VECT\_WORK\_SET,
MSG\_VECT\_C\_CENTER,
MSG\_ADJUST\_CIRCLE,
};
class EDM : public QObject
{
Q_OBJECT
private:
explicit EDM(QObject *parent = nullptr);
static EDM* m_pEdm;
virtual ~EDM();
public slots:
bool EdmSetProtect(bool bProtect);
//
}
EDM.cpp文件部分代码
//edm.cpp edm实现文件
#include "EDM.h"
#include <QDebug>
EDM::EDM(QObject *parent):QObject(parent)
{
}
bool EdmSetProtect(bool bProtect)
{
}
mainWindow.cpp文件部分代码,调用EDM的槽函数EdmSetProtect
MainWindow::MainWindow(QWidget* parent)
{
tThread = new QThread();
edm->moveToThread(tThread);
connect(tThread,&QThread::finished,tThread,&QObject::deleteLater);
connect(tThread,&QThread::finished,edm,&QObject::deleteLater);
connect(this,&MainWindow::signalSetProtect,edm,&EDM::EdmSetProtect);//调用EDM的槽函数EdmSetProtect
}
问题出现的环境背景及自己尝试过哪些方法
去掉Q_OBJECT宏或者加上宏都显示static assertion failed: No Q_OBJECT in the class with the signal错误
so,有人遇到这种问题吗,怎么解决