[Development] export gobal enums to QML

Rutledge Shawn Shawn.Rutledge at digia.com
Tue Sep 2 09:09:27 CEST 2014


On 2 Sep 2014, at 8:36 AM, Bo Thorsen wrote:

> Den 02-09-2014 07:48, Salomon, Florian skrev:
>> Hi,
>> i’d like to know, if there is any possibility to export global enums
>> (defined in a separate header file) to QML?
>> #include “errcodes.h”
>> Class A : QObject
>> {
>>         Q_OBJECT
>>         Q_ENUMS(eErrorIDs)
>> public:
>>         enum globalErrCodes eErrorIDs;
>> }
> 
> Hi Florian,
> 
> No, you have to declare the enums directly in the QObject derived class. 
> The generated moc code won't work if you don't.

There's also Q_GADGET.  In QtQuick.Dialogs it is used to export the StandardButton enum separately.  (see qquickdialogassets_p.h)




More information about the Development mailing list