[Qt-interest] problem with Q_DECLARE_METATYPE

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Mar 15 06:40:18 CET 2010


Hi All,

I'm trying to use my class as a metatype in QList but getting the
following compilation error:

error: expected unqualified-id before 'template'

Here's how I define my class:

<myevent.h>

typedef enum {
    e1 = 1,
    e2,
    e3
} MEvent;

class MyEvent : public QEvent
{
public:
    MyEvent(MEvent ev) : QEvent(QEvent::Type(User+ev)) {
        event = ev;
    }

private:
    MEvent event;
};

Q_DECLARE_METATYPE(MyEvent)

...
...

usage:

QList<MyEvent>

Also, is this usage valid?

QList<MEvent>

Note I'm using the enum, or should declare MEvent too as a metatype ??

Thanks,
-mandeep



More information about the Qt-interest-old mailing list