同上报价

此警告类别由 qmllint 拼写为[syntax.id-quotation]

ID 不需要引号

发生了什么事?

您用引号包围了一个id

为什么这样做不好?

这可能导致 id 和字符串之间的混淆。QML 语言不需要为 id 加上引号,也禁止为 id 使用更复杂的字符串表达式。

示例

import QtQuick

Item {
    id: "root"
}

要修复此警告,请删除引号:

import QtQuick

Item {
    id: root
}

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