このページについて

式内で void を使用しない

この警告カテゴリは、qmllint では「[void] 」と表記されます。

void 式を使用しないでください

何が起きたのか?

JavaScript の void 式が使用されました。

なぜ問題なのか?

void 式は、ほとんどの場合、冗長であり、戻り値を抑制することでコードのロジックを不明瞭にする恐れがあります。また、意味が不明確で可読性が低いという理由から、多くのコーディングスタイルで禁止されています。

例

import QtQuick

Item {
    function undef() {
        return void 0
    }

    function f() {
        return void someFunction()
    }
}

この警告を解消するには、void の使用を削除または置き換えてください:

import QtQuick

Item {
    function undef() {
        return undefined
    }

    function f() {
        somefunction()
    }
}

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