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: undefinedHowever, I get the error:
Unable to assign [undefined] to double
Any way to do this? Otherwise I need to create an extra variable
somevarInitializedto know if it has been initialized already, and this seems counter productive. In javascript, one can just assignundefinedfreely. -
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: undefinedHowever, I get the error:
Unable to assign [undefined] to double
Any way to do this? Otherwise I need to create an extra variable
somevarInitializedto know if it has been initialized already, and this seems counter productive. In javascript, one can just assignundefinedfreely.@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 useundefinedyou have to usevaras 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 useundefinedyou have to usevaras property type:property var somevar: undefined@KroMignon Perfect, thanks!