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