Nesta página

Não use `void` em expressões

Essa categoria de aviso é denominada “ [void] ” pelo qmllint.

Não use expressões `void`

O que aconteceu?

Foi utilizada uma expressão `void` em JavaScript.

Por que isso é ruim?

A expressão `void` tornou-se praticamente redundante e pode obscurecer a lógica de alguns códigos ao suprimir os valores retornados. Ela também é proibida em muitos estilos de código por ser pouco óbvia e de difícil leitura.

Exemplo

import QtQuick

Item {
    function undef() {
        return void 0
    }

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

Para corrigir esse aviso, remova ou substitua o uso de `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.