How do you check if a property is undefined in qml?
This is what I am trying to do:
Button {
id: myButton
text: if (text === "undefined"){"default text"}
}
application-developmentprogrammingqmlubuntu-sdk
How do you check if a property is undefined in qml?
This is what I am trying to do:
Button {
id: myButton
text: if (text === "undefined"){"default text"}
}
Best Answer
Try:
text: text ? text : "default text"
"undefined"
is just a string representation of a reference not referencing anything, just likeNone
, orNULL
in other languages.===
is strict comparison operator, you might want to read this thread: https://stackoverflow.com/questions/523643/difference-between-and-in-javascript