Nesta página

Membro do Id shadows

Essa categoria de aviso é denominada “ [id-shadows-member] ” pelo qmllint.

Id sobrepõe propriedade, método ou sinal

O que aconteceu?

Um id está potencialmente ocultando uma propriedade, um método ou um sinal no mesmo contexto.

Por que isso é ruim?

Você não pode mais acessar a propriedade, o método ou o sinal pelo nome não qualificado. O código que costumava fazer isso passará a acessar silenciosamente o id, o que pode levar a bugs difíceis de detectar.

Exemplo

import QtQuick

Item {
    Item { id: helloWorld }
    property int helloWorld: 42
    Component.onCompleted: console.log(helloWorld) // not 42
}

Para corrigir esse aviso, renomeie o id ou o membro ofuscado.

import QtQuick

Item {
    Item { id: helloWorldId }
    property int helloWorld: 42
    Component.onCompleted: console.log(helloWorld) // now 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.