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
comma.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-comma.html
6\ingroup qmllint-warnings-and-errors
7
8\title Comma
9\brief [comma] Do not use comma expressions.
10
11\qmllintwarningcategory comma
12
13\section1 Do not use comma expressions
14
15\section2 What happened?
16A JavaScript comma expression was used outside of a for loop.
17
18\section2 Why is this bad?
19Comma expressions reduce readability of the code and obscure side-effects.
20
21\section2 Example
22\qml
23import QtQuick
24
25Item {
26 Component.onCompleted: init(config, true), enableLogging(categories), run(1000) // millis
27}
28\endqml
29To fix this warning, refactor the code to use distinct statements for each
30operation. This way, each side effect is explicit instead of happening as part
31of another unrelated operation:
32\qml
33import QtQuick
34
35Item {
36 Component.onCompleted: {
37 init(config, true)
38 enableLogging(categories)
39 run(1000) // millis
40 }
41}
42\endqml
43*/