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
import.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 Warnings occurred while importing
8
\brief [import] The imported module was not found.
9
10
\qmllintwarningcategory import
11
12
\section1 Failed to import module
13
14
\section2 What happened?
15
The module imported via \l{Import Statements}{import statement} was not found.
16
17
This can be caused, for example, by
18
\list
19
\li a typo in the import statement, or
20
\li a user-defined module that was not built, or
21
\li a wrong \l{Import Statements#qml-import-path}{import path}, or
22
\li a missing module
23
\endlist
24
25
\section2 Why is this bad?
26
The application can't run because it can't find a module it relies on.
27
28
\section2 Examples
29
30
\section3 Typo In The Import Statement
31
\qml
32
import QtQuicky // not ok: typo in module name
33
34
Item {
35
}
36
\endqml
37
To fix this warning, correct the typo:
38
\qml
39
import QtQuick // ok: no typo in module name
40
41
Item {
42
}
43
\endqml
44
45
\section3 User-defined module that was not built
46
47
Some tooling like \l{\QMLLS} or \l{qmllint}
48
can't find user-defined modules when they
49
are not built. If your project defines the QML Module you are trying to import, then
50
the QML tooling will not find it until you build it.
51
52
\note If building the module does not help when using \l{\QMLLS}, follow the
53
instructions in
54
\l{Setting up \QMLLS in Your Editor}{\QMLLS setup instructions}
55
and make sure that you communicate the correct build folder to \QMLLS.
56
57
\section3 Wrong import path
58
59
Please refer to \l{Import Statements#qml-import-path}{the QML import path documentation} and to
60
\l{Debugging QML Applications#debugging-module-imports}{the debugging module import documentation}
61
for more information about import paths.
62
63
\section3 Missing module
64
65
If the previous sections did not help to find the imported module, it might be missing.
66
This might be caused by a missing dependency. When using external libraries, verify that they are
67
actually installed, and that their modules end up in an
68
\l{Import Statements#qml-import-path}{import path}.
69
70
\section1 Component was not found
71
72
\section2 What happened?
73
Some component was not found.
74
75
\section2 Why is this bad?
76
The application can't run because it can't instantiate the non-found component.
77
78
\section2 Examples
79
80
\section3 Typo in the component name
81
\qml
82
import QtQuick
83
84
Item {
85
Itemy {} // not ok: typo in name
86
}
87
\endqml
88
To fix this warning, correct the typo:
89
\qml
90
import QtQuick
91
92
Item {
93
Item {} // ok: no typo in name
94
}
95
\endqml
96
97
\section3 Missing import statement
98
99
\qml
100
101
Item { // not ok: must be imported from QtQuick first
102
}
103
\endqml
104
To fix this warning, add the missing module import:
105
\qml
106
import QtQuick
107
108
Item { // ok: was imported from QtQuick
109
}
110
\endqml
111
112
\section1 Import qualifier must start with a capital letter
113
114
\section2 What happened?
115
Some imported module has an invalid qualifier.
116
117
\section2 Why is this bad?
118
The module imported with this invalid qualifier can't be used.
119
120
\section2 Examples
121
122
\qml
123
import QtQuick as qq
124
125
qq.Item {
126
}
127
\endqml
128
To fix this warning, make the import qualifier start with an upper case letter:
129
\qml
130
import QtQuick as Qq
131
132
Qq.Item {
133
}
134
\endqml
135
136
\section1 Unknown import syntax
137
138
\section2 What happened?
139
An import statement is using an invalid \l{Import Statements}{import syntax}.
140
141
\section2 Why is this bad?
142
The application can't run because it can't import a module it relies on.
143
144
\section2 Examples
145
146
\qml
147
import "¯\(ツ)/¯:/path/to/Module"
148
import QtQuick
149
150
Item {
151
}
152
\endqml
153
To fix this warning, use URLs that have an allowed scheme:
154
\qml
155
import "qrc:/path/to/Module"
156
import QtQuick
157
158
Item {
159
}
160
\endqml
161
162
\note This example assumes that you are not using \l{QQmlAbstractUrlInterceptor}{URL handlers}.
163
164
\sa{Import Statements}
165
166
*/
qtdeclarative
src
qml
doc
src
qmllint
import.qdoc
Generated on
for Qt by
1.16.1