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
shadow.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-shadow.html
6\ingroup qmllint-warnings-and-errors
7
8\title Shadow
9\brief [shadow] A member shadows another member.
10
11\qmllintwarningcategory shadow
12
13\section1 Signal or method already exists in base type
14
15\section2 What happened?
16A member in the current component has the same name as a signal or method from a base class.
17
18Note that properties shadowing other properties are handled by the \l{Property override} category.
19
20\section2 Why is that bad?
21The shadowed signal or method can't be used anymore. It makes the code more difficult to read
22and may cause confusion.
23
24\section2 Example
25\qml
26import QtQuick
27
28Item {
29 component Base: Item { signal f(); }
30 Base {
31 property int f: 42
32 }
33}
34\endqml
35
36To fix this warning, rename the signal \c{f} or the shadowing \c{int} property.
37
38\qml
39import QtQuick
40
41Item {
42 component Base: Item { signal f(); }
43 Base {
44 property int notF: 42
45 }
46}
47\endqml
48*/