Hi,

This is unfortunately not possible currently. I tried hacking around but the
QQmlSA API simply doesn't allow for it at the moment.

Several things are missing before this can be enforced in one way or another:

-There is no way to specify whether a QML enum should be scoped or unscoped.
 They are always accessible in both forms. Therefore, there is also no
 mechanism to restrict one form in favor of the other.

-QQmlSA doesn't understand enums at all. The only thing it knows is whether a
 scope is a QQmlSA::ScopeType::EnumSope or not. It is not possible to query the
 enums of a type or to get its keys. This needs to be added.

I have created the following tickets to track these issues:
https://bugreports.qt.io/browse/QTBUG-139628
https://bugreports.qt.io/browse/QTBUG-139629

Hopefully we can get QQmlSA to a more complete state soon.

Best regards,
Oliver De Cannière


________________________________
From: Interest <interest-boun...@qt-project.org> on behalf of A. Klitzing 
<aklitz...@gmail.com>
Sent: Thursday, 28 August 2025 15:17
To: interest@qt-project.org <interest@qt-project.org>
Subject: [Interest] Scoped enums in QML and plugin of qmllint

Hi there,

We are using RegisterEnumClassesUnscoped=false for our exposed C++
enums. Now we have also defined enums directly in QML. In QML as well,
both notations are possible. We would like to restrict this so that
only the long form is allowed. Is there an equivalent mechanism for
QML enums?

Furthermore, we tried to move this check into a custom plugin for
qmllint. However, we are currently stuck because so far we have not
found a way to locate an "enum" of an QQmlSA::Element. How can we
access it in a QQmlSA::ElementPass? In addition, the usage of the enum
ultimately ends up in a QQmlSA::BindingType::Script. How can we then
continue to access the actual usage locations from there?

Best regards
   André Klitzing
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

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

Reply via email to