Reputation: 58
I have the following property defined, for example:
property Gradient greenGradient: Gradient {
GradientStop {
position: 0.0
color: "#00f03b"
}
GradientStop {
position: 1.0
color: "#3cb53b"
}
}
In QtCreator (v3.5.0, running in Windows7) when I do a
Tools->QML/JS->Reformat File
it changes my property to the following invalid code:
property Gradient greenGradient: greenGradient: Gradient {
GradientStop {
position: 0.0
color: "#00f03b"
}
GradientStop {
position: 1.0
color: "#3cb53b"
}
}
Am I doing something incorrectly by defining a Component
as a property like this? Rhe QML docs state:
Additionally, any QML object type can be used as a property type. For example:
property Item someItem
property Rectangle someRectangle
Or is it just a bug in the QtCreator reformat function? I tried a few different object types with the same result. Basic types like int
, color
, var
, string
work as expected.
Upvotes: 0
Views: 63
Reputation: 58
I think I found the answer.
The Qt5 docs are silent (or unclear at least) on this topic. However, in a Qt 4.7 doc I found this:
Such object-type properties default to an undefined value.
So, the code would have to read like this instead:
property Gradient greenGradient
greenGradient: Gradient {
GradientStop {
position: 0.0
color: "#00f03b"
}
GradientStop {
position: 1.0
color: "#3cb53b"
}
}
It's worth nothing that both the original and the modified code function the same. The modified version just gets by the QtCreator reformat function without getting messed up.
Upvotes: 0