重复的内联组件

此警告类别由 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" }
}

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