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