Using null in QML
Unsolved
QML and Qt Quick
-
wrote on 23 Jan 2020, 21:30 last edited by
Would it be considered bad practice in qml to initialize a var to null? For instance:
property var X: null
-
wrote on 23 Jan 2020, 22:20 last edited by
I wouldn't think so.
property var x: null property var y: undefined
Note that null is not the same as undefined.
-
I wouldn't think so.
property var x: null property var y: undefined
Note that null is not the same as undefined.
-
@fcarney Is it even necessary in the QML world? Can I just leave it uninitialized like so:
property var X;
and tbh, I am initializing it as null but I am never running null checks when I use it...
wrote on 24 Jan 2020, 15:20 last edited by@Circuits said in Using null in QML:
Is it even necessary in the QML world? Can I just leave it uninitialized like so:
property var X;no, it is undefined if you let it uninitialized.you can test it
property var undefinedVar Component.onCompleted: console.log(undefinedVar) // output > qml: undefined
3/4