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\page qmllint-warnings-and-errors-unintentional-empty-block.html
6\ingroup qmllint-warnings-and-errors
7
8\title Unintentional empty block
9\brief [unintentional-empty-block] An empty block was created, likely in place of an object literal.
10
11\qmllintwarningcategory unintentional-empty-block
12
13\section1 Unintentional empty block
14
15\section2 What happened?
16An empty block was declared as the expression for a property binding.
17
18You likely intended to declare an empty object literal instead. To do so, wrap
19the literal in parentheses. This is required to disambiguate the literal from
20an empty block.
21
22\section2 Why is that bad?
23Assigning a block with no instructions as a property binding does nothing and
24might confuse the reader. When evaluating that binding, no instructions will be
25executed and the binding will evaluate to undefined.
26
27\section2 Example
28\qml
29import QtQml
30
31QtObject {
32 property var v: {} // This is not an empty object literal!
33}
34\endqml
35To fix this warning, wrap the object literal in parentheses, or remove the
36binding altogether:
37\qml
38import QtQml
39
40QtObject {
41 property var v: ({}) // This is an empty object literal
42}
43\endqml
44*/