本页内容

Shadow

qmllint 将此警告类别拼写为[shadow] 。

基类型中已存在该信号或方法

发生了什么?

当前组件中的某个成员与基类中的信号或方法名称相同。

请注意,掩盖其他属性的属性由“属性覆盖”类别处理。

为什么这不好?

被遮蔽的信号或方法将无法再使用。这会增加代码的可读性难度,并可能造成混淆。

示例

import QtQuick

Item {
    component Base: Item { signal f(); }
    Base {
        property int f: 42
    }
}

要解决此警告,请重命名信号 `f ` 或造成遮蔽的属性 `int `。

import QtQuick

Item {
    component Base: Item { signal f(); }
    Base {
        property int notF: 42
    }
}

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