En esta página

Bloque vacío involuntario

Esta categoría de advertencia se escribe [unintentional-empty-block] por qmllint.

Bloque vacío involuntario

¿Qué ha ocurrido?

Se ha declarado un bloque vacío como expresión de un enlace de propiedad.

Es probable que haya querido declarar un literal de objeto vacío en su lugar. Para ello, encierre el literal entre paréntesis. Esto es necesario para distinguir el literal de un bloque vacío.

¿Por qué es malo?

Asignar un bloque sin instrucciones como una propiedad vinculante no hace nada y puede confundir al lector. Al evaluar ese enlace, no se ejecutará ninguna instrucción y el enlace se evaluará como indefinido.

Ejemplo

import QtQml

QtObject {
    property var v: {} // This is not an empty object literal!
}

Para corregir esta advertencia, encierre el objeto literal entre paréntesis o elimine el enlace:

import QtQml

QtObject {
    property var v: ({}) // This is an empty object literal
}

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