本页内容

枚举条目重复

qmllint 将此警告类别拼写为[duplicate-enum-entries] 。

枚举键 X 已被声明

发生了什么?

一个枚举中包含两个相同的条目。

这有什么问题?

同一个键与多个值相关联。不清楚最终会使用哪个值。

示例

import QtQuick

Item {
    enum E { A = 0, B = 1, C = 2, A = 3 }
}

要解决此警告,请删除或重命名重复的枚举条目:

import QtQuick

Item {
    enum E { A = 0, B = 1, C = 2, D = 3 }
}

© 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.