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?
16
An id is potentially shadowing a property, method, or signal in the same context.
17
18
\section2 Why is that bad?
19
You can't access the property, method, or signal by its unqualified name anymore. Code that
20
used to do so will silently access the id instead, potentially leading
21
to hard-to-spot bugs.
22
23
\section2 Example
24
\qml
25
import QtQuick
26
27
Item {
28
Item { id: helloWorld }
29
property int helloWorld: 42
30
Component.onCompleted: console.log(helloWorld) // not 42
31
}
32
33
\endqml
34
To fix this warning, rename the id or the shadowed member.
35
36
\qml
37
import QtQuick
38
39
Item {
40
Item { id: helloWorldId }
41
property int helloWorld: 42
42
Component.onCompleted: console.log(helloWorld) // now 42
43
}
44
\endqml
45
46
*/
qtdeclarative
src
qml
doc
src
qmllint
id-shadows-member.qdoc
Generated on
for Qt by
1.16.1