このページでは

意図しない空のブロック

この警告カテゴリのスペルは[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.