Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
unintentional-empty-block.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\ingroup qmllint-warnings-and-errors
6
7\title Unintentional empty block
8\brief [unintentional-empty-block] An empty block was created, likely in place of an object literal.
9
10\qmllintwarningcategory unintentional-empty-block
11
12\section1 Unintentional empty block
13
14\section2 What happened?
15An empty block was declared as the expression for a property binding.
16
17You likely intended to declare an empty object literal instead. To do so, wrap
18the literal in parentheses. This is required to disambiguate the literal from
19an empty block.
20
21\section2 Why is that bad?
22Assigning a block with no instructions as a property binding does nothing and
23might confuse the reader. When evaluating that binding, no instructions will be
24executed and the binding will evaluate to undefined.
25
26\section2 Example
27\qml
28import QtQml
29
30QtObject {
31 property var v: {} // This is not an empty object literal!
32}
33\endqml
34To fix this warning, wrap the object literal in parentheses, or remove the
35binding altogether:
36\qml
37import QtQml
38
39QtObject {
40 property var v: ({}) // This is an empty object literal
41}
42\endqml
43*/