我在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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top