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
QQuickTimeLine Class Reference

The QQuickTimeLine class provides a timeline for controlling animations. More...

#include <qquicktimeline_p_p.h>

+ Inheritance diagram for QQuickTimeLine:
+ Collaboration diagram for QQuickTimeLine:

Public Types

enum  SyncMode { LocalSync , GlobalSync }
 

Signals

void updated ()
 Emitted each time the timeline modifies QQuickTimeLineValues.
 
void completed ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QQuickTimeLine (QObject *parent=nullptr)
 Construct a new QQuickTimeLine with the specified parent.
 
 ~QQuickTimeLine ()
 Destroys the time line.
 
SyncMode syncMode () const
 Return the timeline's synchronization mode.
 
void setSyncMode (SyncMode)
 Set the timeline's synchronization mode to syncMode.
 
void pause (QQuickTimeLineObject &, int)
 Pause obj for time milliseconds.
 
void callback (const QQuickTimeLineCallback &)
 Execute the event.
 
void set (QQuickTimeLineValue &, qreal)
 Set the value of timeLineValue.
 
int accel (QQuickTimeLineValue &, qreal velocity, qreal accel)
 Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate.
 
int accel (QQuickTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate over a maximum distance of maxDistance.
 
int accelDistance (QQuickTimeLineValue &, qreal velocity, qreal distance)
 Decelerate timeLineValue from the starting velocity to zero over the given distance.
 
void move (QQuickTimeLineValue &, qreal destination, int time=500)
 Linearly change the timeLineValue from its current value to the given destination value over time milliseconds.
 
void move (QQuickTimeLineValue &, qreal destination, const QEasingCurve &, int time=500)
 Change the timeLineValue from its current value to the given destination value over time milliseconds using the easing curve.
 
void moveBy (QQuickTimeLineValue &, qreal change, int time=500)
 Linearly change the timeLineValue from its current value by the change amount over time milliseconds.
 
void moveBy (QQuickTimeLineValue &, qreal change, const QEasingCurve &, int time=500)
 Change the timeLineValue from its current value by the change amount over time milliseconds using the easing curve.
 
void sync ()
 
void setSyncPoint (int)
 
int syncPoint () const
 
void sync (QQuickTimeLineValue &)
 Synchronize the end point of timeLineValue to the endpoint of the longest action cursrently scheduled in the timeline.
 
void sync (QQuickTimeLineValue &, QQuickTimeLineValue &)
 Synchronize the end point of timeLineValue to the endpoint of syncTo within this timeline.
 
void reset (QQuickTimeLineValue &)
 Cancel (but don't complete) all scheduled actions for timeLineValue.
 
void complete ()
 Completes the timeline.
 
void clear ()
 Resets the timeline.
 
bool isActive () const
 Returns true if the timeline is active.
 
int time () const
 
int duration () const override
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

void updateCurrentTime (int) override
 
void debugAnimation (QDebug d) const override
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Friends

class QQuickTimeLineObject
 
struct QQuickTimeLinePrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

The QQuickTimeLine class provides a timeline for controlling animations.

QQuickTimeLine is similar to QTimeLine except: \list

  • It updates QQuickTimeLineValue instances directly, rather than maintaining a single current value.

For example, the following animates a simple value over 200 milliseconds:

tl.move(v, 100., 200);
tl.start()
The QQuickTimeLineValue class provides a value that can be modified by QQuickTimeLine.
The QQuickTimeLine class provides a timeline for controlling animations.
void move(QQuickTimeLineValue &, qreal destination, int time=500)
Linearly change the timeLineValue from its current value to the given destination value over time mil...
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]

If your program needs to know when values are changed, it can either connect to the QQuickTimeLine's updated() signal, or inherit from QQuickTimeLineValue and reimplement the QQuickTimeLineValue::setValue() method.

  • Supports multiple QQuickTimeLineValue, arbitrary start and end values and allows animations to be strung together for more complex effects.

For example, the following animation moves the x and y coordinates of an object from wherever they are to the position (100, 100) in 50 milliseconds and then further animates them to (100, 200) in 50 milliseconds:

tl.start();
tl.move(x, 100., 50);
tl.move(y, 100., 50);
tl.move(y, 200., 50);
GLint GLint GLint GLint GLint x
[0]
GLint y

Actions scheduled within the same event loop tick are scheduled synchronously against each other, regardless of the wall time between the scheduling. Synchronized scheduling applies both to within the same QQuickTimeLine and across separate QQuickTimeLine's within the same process.

\endlist

Currently easing functions are not supported.

Definition at line 29 of file qquicktimeline_p_p.h.

Member Enumeration Documentation

◆ SyncMode

Enumerator
LocalSync 
GlobalSync 

Definition at line 36 of file qquicktimeline_p_p.h.

Constructor & Destructor Documentation

◆ QQuickTimeLine()

QQuickTimeLine::QQuickTimeLine ( QObject * parent = nullptr)

Construct a new QQuickTimeLine with the specified parent.

Definition at line 283 of file qquicktimeline.cpp.

◆ ~QQuickTimeLine()

QQuickTimeLine::~QQuickTimeLine ( )

Destroys the time line.

Any inprogress animations are canceled, but not completed.

Definition at line 293 of file qquicktimeline.cpp.

Member Function Documentation

◆ accel() [1/2]

int QQuickTimeLine::accel ( QQuickTimeLineValue & timeLineValue,
qreal velocity,
qreal acceleration )

Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate.

Although the acceleration is technically a deceleration, it should always be positive. The QQuickTimeLine will ensure that the deceleration is in the opposite direction to the initial velocity.

Definition at line 357 of file qquicktimeline.cpp.

◆ accel() [2/2]

int QQuickTimeLine::accel ( QQuickTimeLineValue & timeLineValue,
qreal velocity,
qreal acceleration,
qreal maxDistance )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate over a maximum distance of maxDistance.

If necessary, QQuickTimeLine will reduce the acceleration to ensure that the entire operation does not require a move of more than maxDistance. maxDistance should always be positive.

Definition at line 384 of file qquicktimeline.cpp.

◆ accelDistance()

int QQuickTimeLine::accelDistance ( QQuickTimeLineValue & timeLineValue,
qreal velocity,
qreal distance )

Decelerate timeLineValue from the starting velocity to zero over the given distance.

This is like accel(), but the QQuickTimeLine calculates the exact deceleration to use.

distance should be positive.

Definition at line 414 of file qquicktimeline.cpp.

◆ callback()

void QQuickTimeLine::callback ( const QQuickTimeLineCallback & callback)

Execute the event.

Definition at line 336 of file qquicktimeline.cpp.

◆ clear()

void QQuickTimeLine::clear ( )

Resets the timeline.

All queued actions are discarded and QQuickTimeLineValue's retain their current value. For example,

tl.move(v, 100., 1000.);
// 500 ms passes
// v.value() == 50.
tl.clear();
// v.value() == 50.
void clear()
Resets the timeline.

Definition at line 636 of file qquicktimeline.cpp.

◆ complete()

void QQuickTimeLine::complete ( )

Completes the timeline.

All queued actions are played to completion, and then discarded. For example,

tl.move(v, 100., 1000.);
// 500 ms passes
// v.value() == 50.
tl.complete();
// v.value() == 100.
void complete()
Completes the timeline.

Definition at line 619 of file qquicktimeline.cpp.

◆ completed

void QQuickTimeLine::completed ( )
signal

◆ debugAnimation()

void QQuickTimeLine::debugAnimation ( QDebug d) const
overrideprotectedvirtual

Reimplemented from QAbstractAnimationJob.

Definition at line 694 of file qquicktimeline.cpp.

◆ duration()

int QQuickTimeLine::duration ( ) const
overridevirtual

Reimplemented from QAbstractAnimationJob.

Definition at line 490 of file qquicktimeline.cpp.

◆ isActive()

bool QQuickTimeLine::isActive ( ) const

Returns true if the timeline is active.

An active timeline is one where QQuickTimeLineValue actions are still pending.

Definition at line 602 of file qquicktimeline.cpp.

◆ move() [1/2]

void QQuickTimeLine::move ( QQuickTimeLineValue & timeLineValue,
qreal destination,
const QEasingCurve & easing,
int time = 500 )

Change the timeLineValue from its current value to the given destination value over time milliseconds using the easing curve.

Definition at line 445 of file qquicktimeline.cpp.

◆ move() [2/2]

void QQuickTimeLine::move ( QQuickTimeLineValue & timeLineValue,
qreal destination,
int time = 500 )

Linearly change the timeLineValue from its current value to the given destination value over time milliseconds.

Definition at line 434 of file qquicktimeline.cpp.

◆ moveBy() [1/2]

void QQuickTimeLine::moveBy ( QQuickTimeLineValue & timeLineValue,
qreal change,
const QEasingCurve & easing,
int time = 500 )

Change the timeLineValue from its current value by the change amount over time milliseconds using the easing curve.

Definition at line 467 of file qquicktimeline.cpp.

◆ moveBy() [2/2]

void QQuickTimeLine::moveBy ( QQuickTimeLineValue & timeLineValue,
qreal change,
int time = 500 )

Linearly change the timeLineValue from its current value by the change amount over time milliseconds.

Definition at line 456 of file qquicktimeline.cpp.

◆ pause()

void QQuickTimeLine::pause ( QQuickTimeLineObject & obj,
int time )

Pause obj for time milliseconds.

Definition at line 326 of file qquicktimeline.cpp.

◆ reset()

void QQuickTimeLine::reset ( QQuickTimeLineValue & timeLineValue)

Cancel (but don't complete) all scheduled actions for timeLineValue.

Definition at line 477 of file qquicktimeline.cpp.

◆ set()

void QQuickTimeLine::set ( QQuickTimeLineValue & timeLineValue,
qreal value )

Set the value of timeLineValue.

Definition at line 345 of file qquicktimeline.cpp.

◆ setSyncMode()

void QQuickTimeLine::setSyncMode ( SyncMode syncMode)

Set the timeline's synchronization mode to syncMode.

Definition at line 318 of file qquicktimeline.cpp.

◆ setSyncPoint()

void QQuickTimeLine::setSyncPoint ( int sp)

Temporary hack.

Definition at line 583 of file qquicktimeline.cpp.

◆ sync() [1/3]

void QQuickTimeLine::sync ( )

◆ sync() [2/3]

void QQuickTimeLine::sync ( QQuickTimeLineValue & timeLineValue)

Synchronize the end point of timeLineValue to the endpoint of the longest action cursrently scheduled in the timeline.

In pseudo-code, this is equivalent to:

QQuickTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))

Definition at line 531 of file qquicktimeline.cpp.

◆ sync() [3/3]

void QQuickTimeLine::sync ( QQuickTimeLineValue & timeLineValue,
QQuickTimeLineValue & syncTo )

Synchronize the end point of timeLineValue to the endpoint of syncTo within this timeline.

Following operations on timeLineValue in this timeline will be scheduled after all the currently scheduled actions on syncTo are complete. In pseudo-code this is equivalent to:

QQuickTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))

Definition at line 506 of file qquicktimeline.cpp.

◆ syncMode()

QQuickTimeLine::SyncMode QQuickTimeLine::syncMode ( ) const

Return the timeline's synchronization mode.

Definition at line 310 of file qquicktimeline.cpp.

◆ syncPoint()

int QQuickTimeLine::syncPoint ( ) const

Temporary hack.

Definition at line 593 of file qquicktimeline.cpp.

◆ time()

int QQuickTimeLine::time ( ) const

Definition at line 646 of file qquicktimeline.cpp.

◆ updateCurrentTime()

void QQuickTimeLine::updateCurrentTime ( int v)
overrideprotectedvirtual

GfxClock::isActive()

Reimplemented from QAbstractAnimationJob.

Definition at line 658 of file qquicktimeline.cpp.

◆ updated

void QQuickTimeLine::updated ( )
signal

Emitted each time the timeline modifies QQuickTimeLineValues.

Even if multiple QQuickTimeLineValues are changed, this signal is only emitted once for each clock tick.

Friends And Related Symbol Documentation

◆ QQuickTimeLineObject

friend class QQuickTimeLineObject
friend

Definition at line 79 of file qquicktimeline_p_p.h.

◆ QQuickTimeLinePrivate

friend struct QQuickTimeLinePrivate
friend

Definition at line 80 of file qquicktimeline_p_p.h.


The documentation for this class was generated from the following files: