ParentAnimation QML Type
親の値の変化をアニメーション表示します。詳細...
| Import Statement: | import QtQuick |
| Inherits: |
プロパティ
詳細な説明
ParentAnimationは、Item の親要素の変更をアニメーション化するために使用されます。
たとえば、以下のParentChange は、クリックされるとblueRect をredRect の子要素に変更します。遷移中に適用されるNumberAnimation を定義するParentAnimationを含めることで、アイテムが新しい親要素に移動する際にスムーズにアニメーションされるようになります。
import QtQuick
Item {
width: 200; height: 100
Rectangle {
id: redRect
width: 100; height: 100
color: "red"
}
Rectangle {
id: blueRect
x: redRect.width
width: 50; height: 50
color: "blue"
states: State {
name: "reparented"
ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 }
}
transitions: Transition {
ParentAnimation {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
}
MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" }
}
}ParentAnimation には、任意の数のアニメーションを含めることができます。これらのアニメーションは並列で実行されます。順次実行するには、SequentialAnimation 内に定義してください。
クリッピングが有効になっているアイテム間で親を変更する場合など、クリッピングが無効になっている別のアイテムを介して親の変更をアニメーション化すると便利な場合があります。そのようなアイテムは、via プロパティを使用して設定できます。
ParentAnimationは通常、Transition 内でParentChange と組み合わせて使用されます。この方法で使用すると、状態の変更中に発生したすべてのParentChange に対してアニメーションが適用されます。これは、target プロパティを使用して特定のターゲットアイテムを設定することで上書きできます。
『Qt Quick 』の「アニメーションと遷移」および「Qt Quick の例 - アニメーション」も参照してください 。
プロパティのドキュメント
newParent : Item
アニメーションのターゲットとなる新しい親要素。
ParentAnimation がTransition 内で定義されている場合、この値はTransition の終了状態で定義された値がデフォルトとなります。
target : Item
親要素を変更する対象の要素。
トランジションで使用する場合、ターゲットが指定されていないと、すべてのParentChange のインスタンスはParentAnimation によってアニメーション処理されます。
via : Item
親を変更する対象のアイテム。これにより、旧親と新親の両方がクリップされている場合でも、クリップされていないアニメーションを実行できるようになります。
ParentAnimation {
target: myItem
via: topLevelItem
// ...
}注:これは 、`ParentAnimation `が`Transition `内で`ParentChange`と組み合わせて使用されている場合にのみ機能します。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.