aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/qmllint/unresolved-alias.qdoc
blob: 63b02613ddd4a6c08db936d0f3e9596f3915afd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\page qmllint-warnings-and-errors-unresolved-alias.html
\ingroup qmllint-warnings-and-errors

\title Unresolved Alias
\brief Property of property alias was not found.

\section1 Unresolved Alias

\section2 What happened?
A property alias should hold a reference to another property, see also
\l{QML Object Attributes#property-aliases}{QML Object Attributes - Property Aliases}.
In this case, it holds a reference to a property that was not found.

\section2 Why is this bad?
Instances of components with unresolved alias will not be created at runtime:
they will be null instead.

\section2 Example
\qml
import QtQuick

Item {
    id: someId
    property int helloWorld

    property alias helloWorldAlias: helloWorld      // not ok: aliases have to refer by id
    property alias helloWorldAlias2: someId.helloWorlddd    // not ok: no helloWorlddd in someId
    property alias helloWorldAlias3: someIddd.helloWorld    // not ok: someIddd does not exist
}

\endqml
You can fix this warning by making sure that the id and the properties of the alias property
really do exist:
\qml
import QtQuick

Item {
    id: someId
    property int helloWorld

    property alias helloWorldAlias: someId.helloWorld   // ok: alias refers by id
    property alias helloWorldAlias2: someId.helloWorld  // ok: helloWorld does exist in someId
    property alias helloWorldAlias3: someId.helloWorld  // ok: someId does exist
}
\endqml
*/