[Interest] Qt 6.5.2 and qmllint questions/issues

Ulf Hermann ulf.hermann at qt.io
Wed Aug 30 15:58:03 CEST 2023


You can expose the type as both a value type and a namespace:

struct TestGadget
{
     Q_GADGET
     QML_NAMED_ELEMENT(testGadget)
     Q_PROPERTY(int value MEMBER value)

public:
     enum class GadgetEnum
     {
         OptionA,
         OptionB,
         OptionC,
     };
     Q_ENUM(GadgetEnum)
};

struct TestGadgetDerived : TestGadget
{
     Q_GADGET
};

namespace TestGadgetEnums {
     Q_NAMESPACE
     QML_FOREIGN_NAMESPACE(TestGadgetDerived)
     QML_NAMED_ELEMENT(TestGadget)
}

The derived type is not strictly necessary, but if you expose the exact 
same type twice, tooling may currently get confused in certain 
situations. We will fix that soon-ish.

There is unfortunately a lot of outdated information about the QML type 
system all over the internet.

best regards,
Ulf Hermann


More information about the Interest mailing list