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
missing-property.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-missing-property.html
6
\ingroup qmllint-warnings-and-errors
7
8
\title Missing property
9
\brief [missing-property] Binding a value to a non-existing property.
10
11
\qmllintwarningcategory missing-property
12
13
\section1 Can't assign to non-existent default property
14
15
\section2 What happened?
16
You assigned an object to a non-existing default property.
17
18
\section2 Why is this bad?
19
The QML engine can't assign this object at runtime.
20
21
\section2 Example
22
\qml
23
import QtQuick
24
25
Item {
26
component MyType: QtObject { property Item myItem; }
27
28
MyType {
29
Item {}
30
}
31
}
32
33
\endqml
34
To fix this warning, specify the property you want to bind to or, if you are the author
35
of the type, mark a property as default:
36
\qml
37
import QtQuick
38
39
Item {
40
component MyType: QtObject { property Item myItem; }
41
42
MyType {
43
myItem: Item {}
44
}
45
46
component AlternativeMyType: QtObject { default property Item myItem; }
47
48
AlternativeMyType {
49
Item {} // bound to myItem via default property
50
}
51
}
52
\endqml
53
54
\section1 Property does not exist
55
56
\section2 What happened?
57
You assigned an expression to a non-existing property.
58
59
\section2 Why is this bad?
60
The QML engine can't assign this expression at runtime.
61
62
\section2 Example
63
\qml
64
import QtQuick
65
66
Item {
67
property int myInt
68
myItn: 42
69
}
70
71
\endqml
72
To fix this warning, remove the binding or correct a possible typo:
73
\qml
74
import QtQuick
75
76
Item {
77
property int myInt
78
myInt: 42
79
}
80
81
\endqml
82
83
\section1 Member not found on type
84
85
\section2 What happened?
86
You accessed a member in a field member expression that can't be found by QML tooling.
87
88
A field member expression is an expression of the form \c {someId.someProperty}.
89
90
\section2 Why is this bad?
91
The QML tooling can't find this member, and the QML engine probably can't either.
92
93
\section2 Example
94
\qml
95
import QtQuick
96
97
Item {
98
id: self
99
property int myInt
100
property int myInt2: 1 + self.myItn
101
}
102
103
\endqml
104
To fix this warning, remove the binding or correct a possible typo:
105
\qml
106
import QtQuick
107
108
Item {
109
id: self
110
property int myInt
111
property int myInt2: 1 + self.myInt
112
}
113
114
\endqml
115
116
*/
qtdeclarative
src
qml
doc
src
qmllint
missing-property.qdoc
Generated on
for Qt by
1.14.0