未使用的进口

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

未使用的导入

发生了什么?

您使用import 语句导入了一个 QML 模块,但没有使用它的任何类型。

为什么会这样?

import 语句声明了对 QML 模块的依赖,但实际上并不需要。这会影响代码的可读性以及 QML 引擎和工具的性能,因为它们要处理一个不必要的 QML 模块。

示例

import QtQuick
import QtQuick.Controls

Item {}

要修复此警告,请删除未使用的导入:

import QtQuick

Item {}

© 2025 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.