本页内容

重复的内联组件

qmllint 将此警告类别拼写为[duplicate-inline-component] 。

内联组件重复

发生了什么?

两个内联组件具有相同的名称。

这有什么问题?

一个名称引用了多个类型,从而导致歧义。这将导致编译失败。

示例

import QtQuick

Item {
    component R : Rectangle { color: "red" }
    component R : Rectangle { color: "blue" } // Fail to compile
}

要解决此警告,请删除或重命名其中一个内联组件:

import QtQuick

Item {
    component RedRectangle : Rectangle { color: "red" }
    component BlueRectangle : Rectangle { color: "blue" }
}

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