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\page qmllint-warnings-and-errors-id-shadows-member.html
6\ingroup qmllint-warnings-and-errors
7
8\title Id shadows member
9\brief [id-shadows-member] An id shadows a member.
10
11\qmllintwarningcategory id-shadows-member
12
13\section1 Id shadows property, method or signal
14
15\section2 What happened?
16An id is potentially shadowing a property, method, or signal in the same context.
17
18\section2 Why is that bad?
19You can't access the property, method, or signal by its unqualified name anymore. Code that
20used to do so will silently access the id instead, potentially leading
21to hard-to-spot bugs.
22
23\section2 Example
24\qml
25import QtQuick
26
27Item {
28 Item { id: helloWorld }
29 property int helloWorld: 42
30 Component.onCompleted: console.log(helloWorld) // not 42
31}
32
33\endqml
34To fix this warning, rename the id or the shadowed member.
35
36\qml
37import QtQuick
38
39Item {
40 Item { id: helloWorldId }
41 property int helloWorld: 42
42 Component.onCompleted: console.log(helloWorld) // now 42
43}
44\endqml
45
46*/