令人困惑的表达式语句
此警告类别由 qmllint 拼写[confusing-expression-statement] 。
表达式语句无明显效果
发生了什么事?
您使用了没有明显效果的表达式语句。
为什么这样做不好?
它使代码更难阅读,并可能引起混淆。通常,这表明某些表达式结果被忽略了。
表达式语句被编译成字节码,并在运行时进行评估,尽管没有任何效果。
示例
import QtQuick Item { function add(a: int, b: int) : int { a + b } }
要修复此警告,请删除无影响的表达式或使用表达式结果。
import QtQuick Item { function add(a: int, b: int) : int { return a + b } }
© 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.