error: invalid use of incomplete type 'struct QMetaEnum'
Hello,
I am new to Qt and C++ and just migrating from C# and .Net framework witch left me with a bitter taste in programming.
I am trying to get familiar with Qt development and came across this problem while trying to get strings from enum values.
I have used this link as a reference:
http://labs.trolltech.com/blogs/2008...g-enum-values/
and used the ENUM_NAME macro defined therea as follow
Code:
QString strTag
= ENUM_NAME
(Cat,Cat
::CatType,this
->m_catType
);
where Cat is the a class that inherits QObject and has the Q_OBJECT macro inside, and CatType is and enumeration
Code:
enum CatType{MAIDANEZA,CHARTREUX,PERSIAN};
parsed with the Q_ENUMS macro.
I get the following error:
cat.cpp:14:error: invalid use of incomplete type 'struct QMetaEnum'
qobjectdefs.h:240: error: forward declaration of 'struct QMetaEnum'
What could be the problem?
Re: error: invalid use of incomplete type 'struct QMetaEnum'
can you post your header file, including the includes?
Re: error: invalid use of incomplete type 'struct QMetaEnum'
Code:
#ifndef CAT_H
#define CAT_H
#include <QObject>
#define ENUM_NAME(o,e,v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKey((v)))
{
Q_OBJECT
Q_ENUMS(CatType)
public:
enum CatType{MAIDANEZA,CHARTREUX,PERSIAN};
CatType Kind;
{
qDebug()<<QString("THIS IS A CAT TAG");
strTag += ENUM_NAME(Cat,Cat::CatType,this->Kind);
return strTag;
};
};
#endif // CAT_H
Re: error: invalid use of incomplete type 'struct QMetaEnum'
hmm, what happens if you add #include <QMetaEnum>?