[Interest] PropertyAction doesn't work with anchors
Tomasz Olszak
olszak.tomasz at gmail.com
Thu Aug 6 08:33:42 CEST 2015
2015-08-06 7:55 GMT+02:00 Ruslan Moukhlynin <ruslan at khvmntk.ru>:
> Yes, but that isn't mandatory.
> Anyway what can I do if I don't want animation but immediate change?
>
>
> 06.08.2015 14:43, Dmitry Volosnykh пишет:
>
> When using AnchorChanges in states, you should refer to AnchorAnimation in
> transitions. See http://doc.qt.io/qt-5/qml-qtquick-anchoranimation.html
>
> On Thu, Aug 6, 2015 at 1:58 AM, Ruslan Moukhlynin <ruslan at khvmntk.ru> wrote:
>>
>> Unfortunately that doesn't work too.
>> I've tried:
>>
>> in states:
>> ...
>> AnchorChanges {
>> target: rect
>> anchors {
>> top: undefined
>> bottom: parent.bottom
>> }
>> }
>> ...
>>
>> and so, in transitions:
>>
>> ...
>> PropertyAction {
>> target: rect
>> properties: "anchors"
>> }
>> ...
>>
>>
>>
>> 05.08.2015 17:52, Dmitry Volosnykh пишет:
>>
>> What if you specify a single property: "anchors" and set it to object
>> value: { "bottom": 100; "top": 100 }
>>
>> PS. Just a suggestion. Have not done something similar by myself.
>>
>> On Wed, Aug 5, 2015 at 2:33 AM, Ruslan Moukhlynin <ruslan at khvmntk.ru>
>> wrote:
>>>
>>> Suppose we have following code:
>>>
>>> Rectangle {
>>>
>>> id: rect
>>>
>>> width: 100
>>>
>>> height: 100
>>>
>>>
>>>
>>> MouseArea {
>>>
>>> anchors.fill: parent
>>>
>>> onClicked: {
>>>
>>> rect.state = "state1"
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> states: [
>>>
>>> State {
>>>
>>> name: "state1"
>>>
>>> AnchorChanges {
>>>
>>> target: rect
>>>
>>> anchors.bottom: parent.bottom
>>>
>>> anchors.top: undefined
>>>
>>> }
>>>
>>> PropertyChanges {
>>>
>>> target: rect
>>>
>>> color: "red"
>>>
>>> }
>>>
>>> }
>>>
>>> ]
>>>
>>> transitions: [
>>>
>>> Transition {
>>>
>>> SequentialAnimation {
>>>
>>> PropertyAction {
>>>
>>> target: rect
>>>
>>> properties: "anchors.bottom,anchors.top"
>>>
>>> value: "100"
>>>
>>> }
>>>
>>> PropertyAnimation {
>>>
>>> target: rect
>>>
>>> property: "color"
>>>
>>> duration: 1000
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> ]
>>>
>>> }
>>>
>>>
>>> anchors should be changed immediately but that not happens.
>>> PropertyAction works fine with some another properties but not with anchors.
>>> --
>>> With best regards,
>>> Ruslan Moukhlynin
>>>
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>
>>
>>
>> --
>> With best regards,
>> Ruslan Moukhlynin
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> --
> With best regards,
> Ruslan Moukhlynin
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
Instead of PropertyAction try to use
AnchorAnimation {duration: 0}
or
ScriptAction {
script: {
rect.anchors.bottom = Qt.binding(function(){return rect.parent.bottom})
rect.anchors.top = Qt.binding(function(){return rect.parent.top})
}
}
or
place
anchors.bottom: rect.parent.bottom
anchors.top: rect.parent.top
in PropertyChanges
I don't know the details but seems like AnchorChanges is not superset
od PropertyChanges but rather something similar. I had some issues
with some specific edge cases it in the past but there are always at
least a few ways to workaround.
More information about the Interest
mailing list