开发者

Why does this Qt header file fail to get parsed by moc?

开发者 https://www.devze.com 2023-02-01 18:13 出处:网络
I created a new \'C++ library\' project in Qt, which has the following header file: #include \"Test_global.h\"

I created a new 'C++ library' project in Qt, which has the following header file:

#include "Test_global.h"

#includ开发者_运维百科e <QString>
#include <QTcpServer>

class TESTSHARED_EXPORT Test : QTcpServer
{
    Q_OJECT

public:

    Test();
    ~Test();

signals:

    void NewMessage(QString);
};

(The implementation file is basically empty.)

When I try to build the object, I get errors:

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()'

So it looks like moc isn't processing the file at all. What have I done wrong?


It should be Q_OBJECT, not Q_OJECT.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号