Set property to undefined in QML
-
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.@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
@KroMignon Perfect, thanks!