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
unresolved-alias.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-unresolved-alias.html
6\ingroup qmllint-warnings-and-errors
7
8\title Unresolved alias
9\brief [unresolved-alias] Property of property alias was not found.
10
11\qmllintwarningcategory unresolved-alias
12
13\section1 Unresolved alias
14
15\section2 What happened?
16A property alias should hold a reference to another property, see also
17\l{QML Object Attributes#property-aliases}{QML Object Attributes - Property Aliases}.
18In this case, it holds a reference to a property that was not found.
19
20\section2 Why is this bad?
21Instances of components with unresolved alias will not be created at runtime:
22they will be null instead.
23
24\section2 Example
25\qml
26import QtQuick
27
28Item {
29 id: someId
30 property int helloWorld
31
32 property alias helloWorldAlias: helloWorld // not ok: aliases have to refer by id
33 property alias helloWorldAlias2: someId.helloWorlddd // not ok: no helloWorlddd in someId
34 property alias helloWorldAlias3: someIddd.helloWorld // not ok: someIddd does not exist
35}
36
37\endqml
38To fix this warning, make sure that the id and the property of the alias property
39really do exist:
40\qml
41import QtQuick
42
43Item {
44 id: someId
45 property int helloWorld
46
47 property alias helloWorldAlias: someId.helloWorld // ok: alias refers by id
48 property alias helloWorldAlias2: someId.helloWorld // ok: helloWorld does exist in someId
49 property alias helloWorldAlias3: someId.helloWorld // ok: someId does exist
50}
51\endqml
52*/