[Interest] C++ enums undefined in QML

Rutledge Shawn Shawn.Rutledge at digia.com
Fri Nov 15 13:57:05 CET 2013

On 15 Nov 2013, at 1:32 PM, Guido Seifert wrote:

> Hi,
> No namespaces and no forgotten import.
> It is really strange. The class in which I defined the enums is a QAbstractTableModel,
> which I use as model in QML. As I wrote, everything works perfectly, except for the 
> enums. So the code cannot be that wrong. In another project I managed to use my C++ 
> enums in QML. Now I did the same and it works. So far my problem is solved. 
> BUT... I don't understand the difference. The solution which works is that I put 
> the enums in a class of their own. The only differences in the code is that the enum 
> class inherits QObject and not QAbstractTableModel and the enum class is registered with 
> qmlRegisterUncreatableType not with qmlRegisterType.
> The QObject instead of QAbstractTableModel should not make a difference, since
> QAbstractTableModel is also a QObject. And qmlRegisterUncreatableType/qmlRegisterType 
> should not make a difference either.

It might be related to https://bugreports.qt-project.org/browse/QTBUG-33248 somehow although it doesn't sound like you are using a composite type.

More information about the Interest mailing list