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?
16
An empty block was declared as the expression for a property binding.
17
18
You likely intended to declare an empty object literal instead. To do so, wrap
19
the literal in parentheses. This is required to disambiguate the literal from
20
an empty block.
21
22
\section2 Why is that bad?
23
Assigning a block with no instructions as a property binding does nothing and
24
might confuse the reader. When evaluating that binding, no instructions will be
25
executed and the binding will evaluate to undefined.
26
27
\section2 Example
28
\qml
29
import QtQml
30
31
QtObject {
32
property var v: {} // This is not an empty object literal!
33
}
34
\endqml
35
To fix this warning, wrap the object literal in parentheses, or remove the
36
binding altogether:
37
\qml
38
import QtQml
39
40
QtObject {
41
property var v: ({}) // This is an empty object literal
42
}
43
\endqml
44
*/
qtdeclarative
src
qml
doc
src
qmllint
unintentional-empty-block.qdoc
Generated on
for Qt by
1.16.1