Hi Ulf

Thank you for the response. This setup generates a qmllint warning, even in a skeleton QtCreator project. A bug report has been created: https://bugreports.qt.io/browse/QTBUG-116623

Kind regards
Matthew

On 2023/08/30 15:58, Ulf Hermann via Interest wrote:
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
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to