1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qmllint-warnings-and-errors-import.html
6\ingroup qmllint-warnings-and-errors
8\title Warnings Occurred While Importing
9\brief The imported module was not found.
11This warning category contains multiple warnings:
13\li \l{Failed To Import Module}
14\li \l{Component Was Not Found}
15\li \l{Import Qualifier Must Start With A Capital Letter}
16\li \l{Unknown Import Syntax}
19\section1 Failed To Import Module
21\section2 What happened?
22The module imported via \l{Import Statements}{import statement} was not found.
24This can be caused, for example, by
26 \li a typo in the import statement, or
27 \li a user-defined module that was not built, or
28 \li a wrong \l{Import Statements#qml-import-path}{import path}, or
32\section2 Why is this bad?
33The application can't run because it can't find a module it relies on.
37\section3 Typo In The Import Statement
39import QtQuicky // not ok: typo in module name
44You can fix this warning by correcting the typo:
46import QtQuick // ok: no typo in module name
52\section3 User-Defined Module That Was Not Built
54Some tooling like \l{\QMLLS Reference}{\QMLLS} or \l{qmllint Reference}{qmllint}
55can't find user-defined modules when they
56are not built. If your project defines the QML Module you are trying to import, then
57the QML tooling will not find it until you build it.
59\note If building the module does not help when using \l{\QMLLS Reference}{\QMLLS}, follow the
61\l{Setting up the \QMLLS in Your Editor}{\QMLLS setup instructions}
62and make sure that you communicate the correct build folder to \QMLLS.
64\section3 Wrong Import Path
66Please refer to \l{Import Statements#qml-import-path}{the QML import path documentation} and to
67\l{Debugging QML Applications#debugging-module-imports}{the debugging module import documentation}
68for more information about import paths.
70\section3 Missing Module
72If the previous sections did not help to find the imported module, it might be missing.
73This might be caused by a missing dependency. When using external libraries, verify that they are
74actually installed, and that their modules end up in an
75\l{Import Statements#qml-import-path}{import path}.
77\section1 Component Was Not Found
79\section2 What happened?
80Some component was not found.
82\section2 Why is this bad?
83The application can't run because it can't instantiate the non-found component.
87\section3 Typo In The Component Name
92 Itemy {} // not ok: typo in name
95You can fix this warning by correcting the typo:
100 Item {} // ok: no typo in name
104\section3 Missing Import Statement
108Item { // not ok: must be imported from QtQuick first
111You can fix this warning by adding the missing module import:
115Item { // ok: was imported from QtQuick
119\section1 Import Qualifier must start with a capital letter
121\section2 What happened?
122Some imported module has an invalid qualifier.
124\section2 Why is this bad?
125The module imported with this invalid qualifier can't be used.
135You can fix this warning by making the import qualifier start with an upper case letter:
143\section1 Unknown Import Syntax
145\section2 What happened?
146An import statement is using an invalid \l{Import Statements}{import syntax}.
148\section2 Why is this bad?
149The application can't run because it can't import a module it relies on.
154import "¯\(ツ)/¯:/path/to/Module"
160You can fix this warning by using URLs that have an allowed scheme:
162import "qrc:/path/to/Module"
169\note This example assumes that you are not using \l{QQmlAbstractUrlInterceptor}{URL handlers}.
171\sa{Import Statements}