Domanda

Ho creato un nuovo progetto 'C ++ library' in Qt, che ha il seguente file di intestazione:

#include "Test_global.h"

#include <QString>
#include <QTcpServer>

class TESTSHARED_EXPORT Test : QTcpServer
{
    Q_OJECT

public:

    Test();
    ~Test();

signals:

    void NewMessage(QString);
};

(Il file di implementazione è praticamente vuoto.)

Quando provo a costruire l'oggetto, ricevo un errore:

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

Quindi sembra moc non sta elaborando il file a tutti. Che ho io torto fatto?

È stato utile?

Soluzione

Dovrebbe essere Q_OBJECT, non Q_OJECT.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top