このページでは

意図しない空のブロック

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

意図しない空のブロック

何が起きたのか?

プロパティバインディングの式として、空のブロックが宣言されました。

おそらく、代わりに空のオブジェクトリテラルを宣言するつもりだったのではないでしょうか。その場合は、リテラルを括弧で囲んでください。これは、リテラルと空のブロックを区別するために必要です。

なぜ問題なのでしょうか?

命令を含まないブロックをプロパティバインディングとして割り当てても何の効果もなく、読者を混乱させる可能性があります。そのバインディングを評価する際、命令は実行されず、バインディングの結果は `undefined` となります。

例

import QtQml

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

この警告を解消するには、オブジェクトリテラルを括弧で囲むか、バインディングを完全に削除してください:

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.