为什么此QT标头文件无法通过MOC解析?
-
13-10-2019 - |
题
我在QT中创建了一个新的“ C ++库”项目,该项目具有以下标头文件:
#include "Test_global.h"
#include <QString>
#include <QTcpServer>
class TESTSHARED_EXPORT Test : QTcpServer
{
Q_OJECT
public:
Test();
~Test();
signals:
void NewMessage(QString);
};
(实现文件基本上是空的。)
当我尝试构建对象时,我会发现错误:
Test.h:8: error: ISO C++ forbids declaration of ‘Q_OJECT’ with no type Test.h:10: error: expected ‘;’ before ‘public’ Test.cpp:3: error: definition of implicitly-declared 'Test::Test()'
所以看起来像 moc
根本不处理文件。我做错了什么?
解决方案
它应该是 Q_OBJECT
, , 不是 Q_OJECT
.
不隶属于 StackOverflow