Set property to undefined in QML
-
wrote on 15 Feb 2022, 12:52 last edited by Developer123
Hello,
I'd like to initialize a property to undefined, to indicate that the property has not been set yet (and check this later):
property real somevar: undefined
However, I get the error:
Unable to assign [undefined] to double
Any way to do this? Otherwise I need to create an extra variable
somevarInitialized
to know if it has been initialized already, and this seems counter productive. In javascript, one can just assignundefined
freely. -
Hello,
I'd like to initialize a property to undefined, to indicate that the property has not been set yet (and check this later):
property real somevar: undefined
However, I get the error:
Unable to assign [undefined] to double
Any way to do this? Otherwise I need to create an extra variable
somevarInitialized
to know if it has been initialized already, and this seems counter productive. In javascript, one can just assignundefined
freely.wrote on 15 Feb 2022, 12:59 last edited by KroMignon@Developer123 said in Initialize property to undefined:
In javascript, one can just assign undefined freely.
AFAIK, you cannot set primary typed properties (like
int
,real
) toundefined
. I don't know anymore where I found this.
If you want to useundefined
you have to usevar
as property type:property var somevar: undefined
-
@Developer123 said in Initialize property to undefined:
In javascript, one can just assign undefined freely.
AFAIK, you cannot set primary typed properties (like
int
,real
) toundefined
. I don't know anymore where I found this.
If you want to useundefined
you have to usevar
as property type:property var somevar: undefined
wrote on 15 Feb 2022, 13:01 last edited by@KroMignon Perfect, thanks!
1/3