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-type.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
\ingroup qmllint-warnings-and-errors
6
7
\title Unresolved type
8
\brief [unresolved-type] A used type was not found.
9
10
\qmllintwarningcategory unresolved-type
11
12
This category contains following warnings:
13
\list
14
\li Type is used but is not resolved
15
\li Type was not found for the return type of method
16
\li Type was not found for the type of parameter in method
17
\li Property has incomplete type; You may be missing an import
18
\li Type of property not found; This is likely due to a missing dependency entry or a type not being exposed declaratively
19
\li Type of property not fully resolved; This is likely due to a missing dependency entry or a type not being exposed declaratively
20
\li Type not found in namespace
21
\endlist
22
23
These warnings usually indicate missing imports or faulty QML modules, depending
24
on whether you are using or writing a QML module.
25
26
\section1 For QML module users
27
28
\section2 What happened?
29
You used a type that was not found by QML tooling.
30
It usually indicates a potential typo, a missing \l{qtqml-syntax-imports.html}{import},
31
or improperly set up import paths.
32
33
\section2 Why is this bad?
34
The type can't be found by QML tooling, and most likely not by the QML engine.
35
36
\section2 Examples
37
\section3 Typo
38
\qml
39
import QtQuick
40
41
Itme { ... } // misspelling of Item
42
\endqml
43
To fix this warning, correct the typo:
44
\qml
45
import QtQuick
46
47
Item { ... }
48
\endqml
49
50
\section3 Missing import statement
51
\qml
52
53
Item { ... }
54
\endqml
55
To fix this warning, import the module that exposes \c Item:
56
\qml
57
import QtQuick
58
59
Item { ... }
60
\endqml
61
62
If adding the import statement does not help, take a look at your
63
\l{Import Statements#QML Import Path}{import paths}.
64
65
If you get this warning via \QMLLS, your \l{Setting up \QMLLS in Your Editor}{setup} might be
66
incomplete.
67
68
\section1 For QML module authors
69
70
\section2 What happened?
71
The QML tooling can't find a type in your QML module. It can be a type that you expose to QML
72
directly or indirectly by using it as a:
73
\list
74
\li Base type
75
\li Property type
76
\li Signal, slot, or \c Q_INVOKABLE parameter type
77
\li \c Q_INVOKABLE return type
78
\endlist
79
80
You might be missing a \l{qtqml-cppintegration-definetypes.html}{declarative type registration}
81
if the unresolved type is exposed by your module.
82
83
Otherwise, your QML module might have undeclared
84
\l{qt-add-qml-module.html#declaring-module-dependencies}{dependencies}
85
to the QML module exposing the unresolved type.
86
87
\section2 Why is this bad?
88
The QML tooling will not work on your types and users of your QML module will get
89
spurious warnings that they can't fix.
90
91
\section2 Examples
92
93
\section3 Missing type registration
94
95
Refer to \l{Defining QML Types from C++} on how to register your types
96
declaratively. Make sure that all types and enums exposed directly and
97
indirectly to QML are registered.
98
99
\section3 Missing QML module dependency
100
101
Let \c MyItem be a C++ type in your QML module:
102
\code
103
class MyItem: public QQuickItem {
104
...
105
QML_ELEMENT
106
...
107
Q_PROPERTY(SomeType someProperty READ someProperty WRITE setSomeProperty NOTIFY somePropertyChanged)
108
...
109
}
110
\endcode
111
112
The QML tooling can't resolve \c MyItem correctly if it can't resolve \c QQuickItem
113
or \c SomeType first. If \c QQuickItem lives in the \c QtQuick QML module and \c SomeType
114
in \c SomeModule, then you need to state these C++ dependencies in the QML module definition.
115
116
To achieve that, \l{qt-add-qml-module.html#declaring-module-dependencies}{add the dependencies}
117
to the QML module definition. This can be done with \c DEPENDENCIES, for example:
118
\code [cmake]
119
qt_add_qml_module(
120
...
121
DEPENDENCIES
122
QtQuick # for QQuickItem to be resolved
123
SomeModule # for SomeType to be resolved
124
)
125
\endcode
126
127
Refer to
128
\l{qt-add-qml-module.html#declaring-module-dependencies}{declaring C++ dependencies between QML modules}
129
for more information.
130
131
*/
qtdeclarative
src
qml
doc
src
qmllint
unresolved-type.qdoc
Generated on
for Qt by
1.16.1