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