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
alias-cycle.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2023 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-alias-cycle.html
6
\ingroup qmllint-warnings-and-errors
7
8
\title Alias cycle
9
\brief [alias-cycle] Alias property is part of an alias cycle.
10
11
\qmllintwarningcategory alias-cycle
12
13
\section1 Alias property is part of an alias cycle
14
15
\section2 What happened?
16
A \l{QML Object Attributes#property-aliases}{property alias} resolves to itself or to another
17
alias resolving to itself.
18
19
Usually, \l{QML Object Attributes#property-aliases}{a property alias} should reference another
20
property either directly, or indirectly by passing through another alias property.
21
22
If a property alias directly or indirectly references itself, then it forms an alias cycle.
23
The warning indicates that the current alias property is inside or references
24
an alias cycle, see \l{#example}{Example}.
25
26
\section2 Why is this bad?
27
Instances of components with alias cycles will not be created at runtime: they will be null instead.
28
29
\section2 Example
30
\qml
31
import QtQuick
32
33
Item {
34
id: someId
35
property alias myself: someId.myself // not ok: referring to itself
36
37
property alias cycle: someId.cycle2 // not ok: indirectly referring to itself
38
property alias cycle2: someId.cycle
39
40
property alias indirect: someId.cycle // not ok: referring to alias indirectly referring to itself
41
}
42
\endqml
43
To fix this warning, break up the alias cycles:
44
\qml
45
import QtQuick
46
47
Item {
48
id: someId
49
Item {
50
id: anotherId
51
property string myself
52
property int cycle
53
}
54
property alias myself: anotherId.myself // ok: referring to a property
55
56
property alias cycle: someId.cycle2 // ok: does not refer to itself anymore
57
property alias cycle2: anotherId.cycle // ok: not a cycle anymore
58
59
property alias indirect: someId.cycle // ok: cycle does not form an alias cycle anymore
60
}
61
\endqml
62
*/
qtdeclarative
src
qml
doc
src
qmllint
alias-cycle.qdoc
Generated on
for Qt by
1.14.0