顶级组件
此警告类别由 qmllint 拼写为[top-level-component]
。
QML 顶级类型不能是组件
发生了什么事?
您使用Component 类型作为 QML 文件的顶级类型。
为什么会这样?
您的 QML 文件本身已经定义了一个组件。使用Component
类型作为顶层类型会把你的组件包装成另一个不必要的组件。
示例
import QtQuick Component { 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.