本页内容

未使用的导入

qmllint 将此警告类别拼写为[unused-imports] 。

未使用的导入

发生了什么?

您使用了import 语句导入了一个 QML 模块,但未使用其中的任何类型。

这有什么问题?

该 import 语句声明了对一个实际上并不需要的 QML 模块的依赖。这会影响代码的可读性,并因迫使 QML 引擎和工具处理不必要的 QML 模块而降低其性能。

示例

import QtQuick
import QtQuick.Controls

Item {}

要解决此警告,请删除未使用的导入语句:

import QtQuick

Item {}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.