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