Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickanimation.cpp File Reference

(01cd43d30e3ca2c4dd94a4a4711604adb9417517)

#include "qquickanimation_p.h"
#include "qquickanimation_p_p.h"
#include "qquickanimatorjob_p.h"
#include <private/qquickstatechangescript_p.h>
#include <private/qqmlcontext_p.h>
#include <qqmlpropertyvaluesource.h>
#include <qqml.h>
#include <qqmlinfo.h>
#include <qqmlexpression.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qqmlmetatype_p.h>
#include <private/qqmlvaluetype_p.h>
#include <private/qqmlproperty_p.h>
#include <private/qqmlengine_p.h>
#include <qvariant.h>
#include <qcolor.h>
#include <qfile.h>
#include "private/qparallelanimationgroupjob_p.h"
#include "private/qsequentialanimationgroupjob_p.h"
#include <QtCore/qset.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
#include <QtCore/qmath.h>
#include "moc_qquickanimation_p.cpp"
Include dependency graph for qquickanimation.cpp:

Go to the source code of this file.

Functions

QVariant _q_interpolateShortestRotation (qreal &f, qreal &t, qreal progress)
 \qmltype RotationAnimation \nativetype QQuickRotationAnimation \inqmlmodule QtQuick\inherits PropertyAnimation
QVariant _q_interpolateClockwiseRotation (qreal &f, qreal &t, qreal progress)
QVariant _q_interpolateCounterclockwiseRotation (qreal &f, qreal &t, qreal progress)

Function Documentation

◆ _q_interpolateClockwiseRotation()

QVariant _q_interpolateClockwiseRotation ( qreal & f,
qreal & t,
qreal progress )

Definition at line 1559 of file qquickanimation.cpp.

◆ _q_interpolateCounterclockwiseRotation()

QVariant _q_interpolateCounterclockwiseRotation ( qreal & f,
qreal & t,
qreal progress )

Definition at line 1570 of file qquickanimation.cpp.

◆ _q_interpolateShortestRotation()

QVariant _q_interpolateShortestRotation ( qreal & f,
qreal & t,
qreal progress )

\qmltype RotationAnimation \nativetype QQuickRotationAnimation \inqmlmodule QtQuick\inherits PropertyAnimation

Animates changes in rotation values.

RotationAnimation is a specialized PropertyAnimation that gives control over the direction of rotation during an animation.

By default, it rotates in the direction of the numerical change; a rotation from 0 to 240 will rotate 240 degrees clockwise, while a rotation from 240 to 0 will rotate 240 degrees counterclockwise. The \l direction property can be set to specify the direction in which the rotation should occur.

In the following example we use RotationAnimation to animate the rotation between states via the shortest path:

import QtQuick
Item {
width: 300; height: 300
Rectangle {
id: rect
width: 150; height: 100; anchors.centerIn: parent
color: "red"
antialiasing: true
states: State {
name: "rotated"
PropertyChanges { target: rect; rotation: 180 }
}
transitions: Transition {
RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
}
}
MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" }
}

Notice the RotationAnimation did not need to set a target value. As a convenience, when used in a transition, RotationAnimation will rotate all properties named "rotation" or "angle". You can override this by providing your own properties via \l {PropertyAnimation::properties}{properties} or \l {PropertyAnimation::property}{property}.

Also, note the \l Rectangle will be rotated around its default \l {Item::}{transformOrigin} (which is Item.Center). To use a different transform origin, set the origin in the PropertyChanges object and apply the change at the start of the animation using PropertyAction. See the PropertyAction documentation for more details.

Like any other animation type, a RotationAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The \l {Animation and Transitions in Qt Quick} documentation shows a variety of methods for creating animations.

See also
{Animation and Transitions in Qt Quick}, {Qt Quick Examples - Animation}

Definition at line 1544 of file qquickanimation.cpp.