PDA

View Full Version : Nested classes and problem with meta-object system



Momergil
18th June 2014, 14:02
Hello!

I want to create a class and nest it inside the unique other class that will be using it. This nested class is a QObject derived one, being a reimplementation of QVariantAnimation.

The problem is that when I put it inside my base class, the compiler states "error 1" after the message "Error: Meta object features not supported for nested classes".



class MessageFrame : public QFrame
{
Q_OBJECT
Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText)
Q_ENUMS(Icon)
Q_ENUMS(TextType)

class MessageFrameAnimator : public QVariantAnimation
{
Q_OBJECT
public:
MessageFrameAnimator(QObject* parent = 0) :
QVariantAnimation(parent)
{}

virtual ~MessageFrameAnimator() {}

protected:
void updateCurrentValue(const QVariant & value) //Does nothing
{
Q_UNUSED(value);
}
};

public:
//...


It's not imperative to use this class as a nested one, but I'm still curious how to solve this problem - if there is any solution to it. Does somebody knows how to nest my class correctly?

Thanks,

Momergil

anda_skoa
18th June 2014, 16:25
That's a limitation of the current implementation of MOC.

I think you can forward declare the nested class and put its declaration into its own header.

Cheers,
_

Momergil
18th June 2014, 18:50
That's a limitation of the current implementation of MOC.

Hmm, I hope this will be fixed in the future...


I think you can forward declare the nested class and put its declaration into its own header.

Cheers,
_

Well, in that case the organization I wanted with this action will be missed anyway :/

Thanks for the reply,

Momergil