Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么moc无法解析此Qt头文件?_Qt_Qt Creator_Qmake_Moc - Fatal编程技术网

为什么moc无法解析此Qt头文件?

为什么moc无法解析此Qt头文件?,qt,qt-creator,qmake,moc,Qt,Qt Creator,Qmake,Moc,我在Qt中创建了一个新的“C++库”项目,该项目具有以下头文件: #include "Test_global.h" #include <QString> #include <QTcpServer> class TESTSHARED_EXPORT Test : QTcpServer { Q_OJECT public: Test(); ~Test(); signals: void NewMessage(QString); }; #

我在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_global.h”
#包括
#包括
类TESTSHARED\u导出测试:qtcserver
{
Q_项目
公众:
Test();
~Test();
信号:
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()' 测试:h:8:错误:ISO C++禁止声明“QooEXECT”,没有类型 Test.h:10:错误:应为“;”在“公开”之前 Test.cpp:3:错误:隐式声明的“Test::Test()的定义”
因此,看起来
moc
根本没有处理该文件。我做错了什么?

应该是
Q\u OBJECT
,而不是
Q\u OBJECT

[Facepalm]为什么我没有看到?