With Qt 5 it was possible to use code like this:
// Test.h
#include <QObject>
#include <QMetaObject>
class LanguageModel;
class Test : public QObject
{
Q_OBJECT
Q_PROPERTY(LanguageModel*, ...)
public:
};
// Test.cpp
#include "Test.h"
#include "LanguageModel.h"
// LanguageModel.h
#include <QObject>
#include <QMetaObject>
class LanguageModel : public QObject
{
Q_OBJECT
}
Now I am trying to convert the project to Qt 6 but the above code fails in the generated "debug\moc_Test.cpp" file with this error message:
C:\Qt\6.1.0\msvc2019_64\include\QtCore\qmetatype.h:778: error: C2338: Type argument of Q_PROPERTY or Q_DECLARE_METATYPE(T*) must be fully defined
Replacing the class forward definition with a direct header include works:
// Test.h
#include <QObject>
#include <QMetaObject>
#include "LanguageModel.h" //class LanguageModel;
class Test : public QObject
{
Q_OBJECT
Q_PROPERTY(LanguageModel*, ...)
public:
};
How can I keep using class defintions instead of including the headers in Qt 6?
Regards,