类型被递归实例化
qmllint 将此警告类别拼写为[type-instantiated-recursively] 。
类型无法递归实例化
发生了什么?
某个组件实例化了自身。
为什么这样不好?
该组件需要自身来实例化自身,从而形成无限循环。QML Runtime会对此组件报错。
示例
// MyComponent.qml
import QtQuick
Item {
MyComponent {}
}要解决此警告,
- 如果这是个错误,请用另一个组件替换该问题组件。
- 将实例化操作推迟到稍后进行,例如使用JavaScript 进行动态 QML 对象创建。
© 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.