qtqproperty

User type in Q_PROPERTY error 'staticMetaObject' is not a member of 'blah'


I have some data types defined as enum in a namespace.

I wanted to use Q_PROPERTY, that would return the data types...

But I get error:

'staticMetaObject' is not a member of 'blah'

So it seems, if I want to create my own types, and use them in functions that are mentioned in Q_PROPERTY, they must be inside a class inheriting QObject and declaring the Q_OBJECT macro ? Isn't that a lot of overhead ?

is there an alternative ?


Solution

  • Maybe you are searching for Q_GADGET? It generates metadata for non QObject derived types. You can have Q_PROPERTY and Q_INVOKABLE within a gadget.

    And yes, there is quite a lot of overhead, if you don't need QObject don't use it. It is like 160 bytes to begin with.