Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
id-shadows-member.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\ingroup qmllint-warnings-and-errors
6
7\title Id shadows member
8\brief [id-shadows-member] An id shadows a member.
9
10\qmllintwarningcategory id-shadows-member
11
12\section1 Id shadows property, method or signal
13
14\section2 What happened?
15An id is potentially shadowing a property, method, or signal in the same context.
16
17\section2 Why is that bad?
18You can't access the property, method, or signal by its unqualified name anymore. Code that
19used to do so will silently access the id instead, potentially leading
20to hard-to-spot bugs.
21
22\section2 Example
23\qml
24import QtQuick
25
26Item {
27 Item { id: helloWorld }
28 property int helloWorld: 42
29 Component.onCompleted: console.log(helloWorld) // not 42
30}
31
32\endqml
33To fix this warning, rename the id or the shadowed member.
34
35\qml
36import QtQuick
37
38Item {
39 Item { id: helloWorldId }
40 property int helloWorld: 42
41 Component.onCompleted: console.log(helloWorld) // now 42
42}
43\endqml
44
45*/