内联组件枚举
qmllint 将此警告类别拼写为[inline-component-enums] 。
在内联组件内部声明的枚举将被忽略
发生了什么?
您在内联组件内部定义了一个枚举。
为什么这样不好?
QML 语言仅允许在 QML 文件的根项内定义枚举。在内联组件内声明的枚举无法使用,即使是在该内联组件内部也是如此。此规则同样适用于在非根 QML 对象内声明的枚举。
示例
要解决此警告,请将枚举声明移至 QML 文件的根元素中:
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.