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
void.qdoc
Go to the documentation of this file.
1// Copyright (C) 2025 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 Do not use void in expressions
8\brief [void] A void expression was used.
9
10\qmllintwarningcategory void
11
12\section1 Do not use void expressions
13
14\section2 What happened?
15A JavaScript void expression was used.
16
17\section2 Why is this bad?
18The void expression has become mostly redundant and can obscure the logic of
19some code by suppressing returned values. It is also prohibited in many code
20styles for being non-obvious and hard to read.
21
22\section2 Example
23\qml
24import QtQuick
25
26Item {
27 function undef() {
28 return void 0
29 }
30
31 function f() {
32 return void someFunction()
33 }
34}
35\endqml
36To fix this warning, remove or replace the use of void:
37\qml
38import QtQuick
39
40Item {
41 function undef() {
42 return undefined
43 }
44
45 function f() {
46 somefunction()
47 }
48}
49\endqml
50*/