Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTimeLine Class Reference

\inmodule QtCore More...

#include <qtimeline.h>

+ Inheritance diagram for QTimeLine:
+ Collaboration diagram for QTimeLine:

Public Types

enum  State { NotRunning , Paused , Running }
 This enum describes the state of the timeline. More...
 
enum  Direction { Forward , Backward }
 This enum describes the direction of the timeline when in \l Running state. More...
 

Public Slots

void start ()
 Starts the timeline.
 
void resume ()
 Resumes the timeline from the current time.
 
void stop ()
 Stops the timeline, causing QTimeLine to enter NotRunning state.
 
void setPaused (bool paused)
 If paused is true, the timeline is paused, causing QTimeLine to enter Paused state.
 
void setCurrentTime (int msec)
 
void toggleDirection ()
 Toggles the direction of the timeline.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

void valueChanged (qreal x, QPrivateSignal)
 QTimeLine emits this signal at regular intervals when in \l Running state, but only if the current value changes.
 
void frameChanged (int, QPrivateSignal)
 QTimeLine emits this signal at regular intervals when in \l Running state, but only if the current frame changes.
 
void stateChanged (QTimeLine::State newState, QPrivateSignal)
 This signal is emitted whenever QTimeLine's state changes.
 
void finished (QPrivateSignal)
 This signal is emitted when QTimeLine finishes (i.e., reaches the end of its time line), and does not loop.
 
- 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

 QTimeLine (int duration=1000, QObject *parent=nullptr)
 Constructs a timeline with a duration of duration milliseconds.
 
virtual ~QTimeLine ()
 Destroys the timeline.
 
State state () const
 Returns the state of the timeline.
 
int loopCount () const
 
void setLoopCount (int count)
 
QBindable< int > bindableLoopCount ()
 
Direction direction () const
 
void setDirection (Direction direction)
 
QBindable< DirectionbindableDirection ()
 
int duration () const
 
void setDuration (int duration)
 
QBindable< int > bindableDuration ()
 
int startFrame () const
 Returns the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0).
 
void setStartFrame (int frame)
 Sets the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0), to frame.
 
int endFrame () const
 Returns the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1).
 
void setEndFrame (int frame)
 Sets the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1), to frame.
 
void setFrameRange (int startFrame, int endFrame)
 Sets the timeline's frame counter to start at startFrame, and end and endFrame.
 
int updateInterval () const
 
void setUpdateInterval (int interval)
 
QBindable< int > bindableUpdateInterval ()
 
QEasingCurve easingCurve () const
 
void setEasingCurve (const QEasingCurve &curve)
 
QBindable< QEasingCurvebindableEasingCurve ()
 
int currentTime () const
 
QBindable< int > bindableCurrentTime ()
 
int currentFrame () const
 Returns the frame corresponding to the current time.
 
qreal currentValue () const
 Returns the value corresponding to the current time.
 
int frameForTime (int msec) const
 Returns the frame corresponding to the time msec.
 
virtual qreal valueForTime (int msec) const
 Returns the timeline value for the time msec.
 
- 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 timerEvent (QTimerEvent *event) override
 \reimp
 
- 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 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)
 

Properties

int duration
 the total duration of the timeline in milliseconds.
 
int updateInterval
 the time in milliseconds between each time QTimeLine updates its current time.
 
int currentTime
 the current time of the time line.
 
Direction direction
 the direction of the timeline when QTimeLine is in \l Running state.
 
int loopCount
 the number of times the timeline should loop before it's finished.
 
QEasingCurve easingCurve
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- 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
 

Detailed Description

\inmodule QtCore

The QTimeLine class provides a timeline for controlling animations.

Since
4.2

It's most commonly used to animate a GUI control by calling a slot periodically. You can construct a timeline by passing its duration in milliseconds to QTimeLine's constructor. The timeline's duration describes for how long the animation will run. Then you set a suitable frame range by calling setFrameRange(). Finally connect the frameChanged() signal to a suitable slot in the widget you wish to animate (for example, \l {QProgressBar::}{setValue()} in QProgressBar). When you proceed to calling start(), QTimeLine will enter Running state, and start emitting frameChanged() at regular intervals, causing your widget's connected property's value to grow from the lower end to the upper and of your frame range, at a steady rate. You can specify the update interval by calling setUpdateInterval(). When done, QTimeLine enters NotRunning state, and emits finished().

Example:

...
progressBar = new QProgressBar(this);
progressBar->setRange(0, 100);
// Construct a 1-second timeline with a frame range of 0 - 100
QTimeLine *timeLine = new QTimeLine(1000, this);
// Clicking the push button will start the progress bar animation
pushButton = new QPushButton(tr("Start animation"), this);
...
void setValue(int value)
void start()
Starts the timeline.
void frameChanged(int, QPrivateSignal)
QTimeLine emits this signal at regular intervals when in \l Running state, but only if the current fr...
void setFrameRange(int startFrame, int endFrame)
Sets the timeline's frame counter to start at startFrame, and end and endFrame.
QTimeLine * timeLine
connect(timeLine, &QTimeLine::frameChanged, progressBar, &QProgressBar::setValue)

By default the timeline runs once, from its beginning to its end, upon which you must call start() again to restart from the beginning. To make the timeline loop, you can call setLoopCount(), passing the number of times the timeline should run before finishing. The direction can also be changed, causing the timeline to run backward, by calling setDirection(). You can also pause and unpause the timeline while it's running by calling setPaused(). For interactive control, the setCurrentTime() function is provided, which sets the time position of the time line directly. Although most useful in NotRunning state (e.g., connected to a valueChanged() signal in a QSlider), this function can be called at any time.

The frame interface is useful for standard widgets, but QTimeLine can be used to control any type of animation. The heart of QTimeLine lies in the valueForTime() function, which generates a value between 0 and 1 for a given time. This value is typically used to describe the steps of an animation, where 0 is the first step of an animation, and 1 is the last step. When running, QTimeLine generates values between 0 and 1 by calling valueForTime() and emitting valueChanged(). By default, valueForTime() applies an interpolation algorithm to generate these value. You can choose from a set of predefined timeline algorithms by calling setEasingCurve().

Note that, by default, QTimeLine uses QEasingCurve::InOutSine, which provides a value that grows slowly, then grows steadily, and finally grows slowly. For a custom timeline, you can reimplement valueForTime(), in which case QTimeLine's easingCurve property is ignored.

See also
QProgressBar, QProgressDialog

Definition at line 18 of file qtimeline.h.

Member Enumeration Documentation

◆ Direction

This enum describes the direction of the timeline when in \l Running state.

\value Forward The current time of the timeline increases with time (i.e., moves from 0 and towards the end / duration).

\value Backward The current time of the timeline decreases with time (i.e., moves from the end / duration and towards 0).

See also
setDirection()
Enumerator
Forward 
Backward 

Definition at line 35 of file qtimeline.h.

◆ State

This enum describes the state of the timeline.

\value NotRunning The timeline is not running. This is the initial state of QTimeLine, and the state QTimeLine reenters when finished. The current time, frame and value remain unchanged until either setCurrentTime() is called, or the timeline is started by calling start().

\value Paused The timeline is paused (i.e., temporarily suspended). Calling setPaused(false) will resume timeline activity.

\value Running The timeline is running. While control is in the event loop, QTimeLine will update its current time at regular intervals, emitting valueChanged() and frameChanged() when appropriate.

See also
state(), stateChanged()
Enumerator
NotRunning 
Paused 
Running 

Definition at line 30 of file qtimeline.h.

Constructor & Destructor Documentation

◆ QTimeLine()

QTimeLine::QTimeLine ( int duration = 1000,
QObject * parent = nullptr )
explicit

Constructs a timeline with a duration of duration milliseconds.

parent is passed to QObject's constructor. The default duration is 1000 milliseconds.

Definition at line 263 of file qtimeline.cpp.

References duration, and setDuration().

+ Here is the call graph for this function:

◆ ~QTimeLine()

QTimeLine::~QTimeLine ( )
virtual

Destroys the timeline.

Definition at line 272 of file qtimeline.cpp.

References d, Running, and stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ bindableCurrentTime()

QBindable< int > QTimeLine::bindableCurrentTime ( )

Definition at line 131 of file qtimeline.cpp.

References d.

◆ bindableDirection()

QBindable< QTimeLine::Direction > QTimeLine::bindableDirection ( )

Definition at line 348 of file qtimeline.cpp.

References d.

◆ bindableDuration()

QBindable< int > QTimeLine::bindableDuration ( )

Definition at line 385 of file qtimeline.cpp.

References d.

◆ bindableEasingCurve()

QBindable< QEasingCurve > QTimeLine::bindableEasingCurve ( )

Definition at line 507 of file qtimeline.cpp.

References d.

◆ bindableLoopCount()

QBindable< int > QTimeLine::bindableLoopCount ( )

Definition at line 311 of file qtimeline.cpp.

References d.

◆ bindableUpdateInterval()

QBindable< int > QTimeLine::bindableUpdateInterval ( )

Definition at line 478 of file qtimeline.cpp.

References d.

◆ currentFrame()

int QTimeLine::currentFrame ( ) const

Returns the frame corresponding to the current time.

See also
currentTime(), frameForTime(), setFrameRange()

Definition at line 547 of file qtimeline.cpp.

References d, and frameForTime().

+ Here is the call graph for this function:

◆ currentTime()

int QTimeLine::currentTime ( ) const

Definition at line 528 of file qtimeline.cpp.

References d.

◆ currentValue()

qreal QTimeLine::currentValue ( ) const

Returns the value corresponding to the current time.

See also
valueForTime(), currentFrame()

Definition at line 558 of file qtimeline.cpp.

References d, and valueForTime().

+ Here is the call graph for this function:

◆ direction()

QTimeLine::Direction QTimeLine::direction ( ) const

Definition at line 331 of file qtimeline.cpp.

References d.

◆ duration()

int QTimeLine::duration ( ) const

Definition at line 366 of file qtimeline.cpp.

References d.

◆ easingCurve()

QEasingCurve QTimeLine::easingCurve ( ) const

Definition at line 495 of file qtimeline.cpp.

References d.

◆ endFrame()

int QTimeLine::endFrame ( ) const

Returns the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1).

See also
setEndFrame(), setFrameRange()

Definition at line 421 of file qtimeline.cpp.

References d.

Referenced by setFrameRange().

+ Here is the caller graph for this function:

◆ finished

void QTimeLine::finished ( QPrivateSignal )
signal

This signal is emitted when QTimeLine finishes (i.e., reaches the end of its time line), and does not loop.

◆ frameChanged

void QTimeLine::frameChanged ( int ,
QPrivateSignal  )
signal

QTimeLine emits this signal at regular intervals when in \l Running state, but only if the current frame changes.

frame is the current frame number.

See also
QTimeLine::setFrameRange(), QTimeLine::updateInterval

◆ frameForTime()

int QTimeLine::frameForTime ( int msec) const

Returns the frame corresponding to the time msec.

This value is calculated using a linear interpolation of the start and end frame, based on the value returned by valueForTime().

See also
valueForTime(), setFrameRange()

Definition at line 571 of file qtimeline.cpp.

References d, Forward, qCeil(), and valueForTime().

Referenced by currentFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loopCount()

int QTimeLine::loopCount ( ) const

Definition at line 299 of file qtimeline.cpp.

References d.

◆ resume

void QTimeLine::resume ( )
slot

Resumes the timeline from the current time.

QTimeLine will reenter Running state, and once it enters the event loop, it will update its current time, frame and value at regular intervals.

In contrast to start(), this function does not restart the timeline before it resumes.

See also
start(), updateInterval(), frameChanged(), valueChanged()

Definition at line 639 of file qtimeline.cpp.

References d, qWarning, Running, and QObject::startTimer().

+ Here is the call graph for this function:

◆ setCurrentTime

void QTimeLine::setCurrentTime ( int msec)
slot

Definition at line 533 of file qtimeline.cpp.

References d.

◆ setDirection()

void QTimeLine::setDirection ( Direction direction)

Definition at line 336 of file qtimeline.cpp.

References d, and direction.

Referenced by toggleDirection().

+ Here is the caller graph for this function:

◆ setDuration()

void QTimeLine::setDuration ( int duration)

Definition at line 371 of file qtimeline.cpp.

References d, duration, and qWarning.

Referenced by QTimeLine().

+ Here is the caller graph for this function:

◆ setEasingCurve()

void QTimeLine::setEasingCurve ( const QEasingCurve & curve)

Definition at line 501 of file qtimeline.cpp.

References d.

◆ setEndFrame()

void QTimeLine::setEndFrame ( int frame)

Sets the end frame, which is the frame corresponding to the end of the timeline (i.e., the frame for which the current value is 1), to frame.

See also
endFrame(), startFrame(), setFrameRange()

Definition at line 433 of file qtimeline.cpp.

References d, and frame.

◆ setFrameRange()

void QTimeLine::setFrameRange ( int startFrame,
int endFrame )

Sets the timeline's frame counter to start at startFrame, and end and endFrame.

For each time value, QTimeLine will find the corresponding frame when you call currentFrame() or frameForTime() by interpolating, using the return value of valueForTime().

When in Running state, QTimeLine also emits the frameChanged() signal when the frame changes.

See also
startFrame(), endFrame(), start(), currentFrame()

Definition at line 450 of file qtimeline.cpp.

References d, endFrame(), and startFrame().

+ Here is the call graph for this function:

◆ setLoopCount()

void QTimeLine::setLoopCount ( int count)

Definition at line 305 of file qtimeline.cpp.

References d.

◆ setPaused

void QTimeLine::setPaused ( bool paused)
slot

If paused is true, the timeline is paused, causing QTimeLine to enter Paused state.

No updates will be signaled until either start() or setPaused(false) is called. If paused is false, the timeline is resumed and continues where it left.

See also
state(), start()

Definition at line 674 of file qtimeline.cpp.

References d, QObject::killTimer(), NotRunning, Paused, qWarning, Running, and QObject::startTimer().

+ Here is the call graph for this function:

◆ setStartFrame()

void QTimeLine::setStartFrame ( int frame)

Sets the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0), to frame.

See also
startFrame(), endFrame(), setFrameRange()

Definition at line 409 of file qtimeline.cpp.

References d, and frame.

◆ setUpdateInterval()

void QTimeLine::setUpdateInterval ( int interval)

Definition at line 473 of file qtimeline.cpp.

References d.

◆ start

void QTimeLine::start ( )
slot

Starts the timeline.

QTimeLine will enter Running state, and once it enters the event loop, it will update its current time, frame and value at regular intervals. The default interval is 40 ms (i.e., 25 times per second). You can change the update interval by calling setUpdateInterval().

The timeline will start from position 0, or the end if going backward. If you want to resume a stopped timeline without restarting, you can call resume() instead.

See also
resume(), updateInterval(), frameChanged(), valueChanged()

Definition at line 611 of file qtimeline.cpp.

References Backward, d, qWarning, Running, and QObject::startTimer().

+ Here is the call graph for this function:

◆ startFrame()

int QTimeLine::startFrame ( ) const

Returns the start frame, which is the frame corresponding to the start of the timeline (i.e., the frame for which the current value is 0).

See also
setStartFrame(), setFrameRange()

Definition at line 397 of file qtimeline.cpp.

References d.

Referenced by setFrameRange().

+ Here is the caller graph for this function:

◆ state()

QTimeLine::State QTimeLine::state ( ) const

Returns the state of the timeline.

See also
start(), setPaused(), stop()

Definition at line 285 of file qtimeline.cpp.

References d.

◆ stateChanged

void QTimeLine::stateChanged ( QTimeLine::State newState,
QPrivateSignal  )
signal

This signal is emitted whenever QTimeLine's state changes.

The new state is newState.

◆ stop

void QTimeLine::stop ( )
slot

Stops the timeline, causing QTimeLine to enter NotRunning state.

See also
start()

Definition at line 657 of file qtimeline.cpp.

References d, QObject::killTimer(), and NotRunning.

Referenced by ~QTimeLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ timerEvent()

void QTimeLine::timerEvent ( QTimerEvent * event)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Definition at line 712 of file qtimeline.cpp.

References d, and Forward.

◆ toggleDirection

void QTimeLine::toggleDirection ( )
slot

Toggles the direction of the timeline.

If the direction was Forward, it becomes Backward, and vice verca.

Existing bindings of \l direction are removed.

See also
setDirection()

Definition at line 703 of file qtimeline.cpp.

References Backward, d, Forward, and setDirection().

+ Here is the call graph for this function:

◆ updateInterval()

int QTimeLine::updateInterval ( ) const

Definition at line 468 of file qtimeline.cpp.

References d.

◆ valueChanged

void QTimeLine::valueChanged ( qreal x,
QPrivateSignal  )
signal

QTimeLine emits this signal at regular intervals when in \l Running state, but only if the current value changes.

value is the current value. value is a number between 0.0 and 1.0

See also
QTimeLine::setDuration(), QTimeLine::valueForTime(), QTimeLine::updateInterval

◆ valueForTime()

qreal QTimeLine::valueForTime ( int msec) const
virtual

Returns the timeline value for the time msec.

The returned value, which varies depending on the curve shape, is always between 0 and 1. If msec is 0, the default implementation always returns 0.

Reimplement this function to provide a custom curve shape for your timeline.

See also
easingCurve, frameForTime()

Definition at line 589 of file qtimeline.cpp.

References d, and qBound().

Referenced by currentValue(), and frameForTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Property Documentation

◆ currentTime

QTimeLine::currentTime
readwrite

the current time of the time line.

When QTimeLine is in Running state, this value is updated continuously as a function of the duration and direction of the timeline. Otherwise, it is value that was current when stop() was called last, or the value set by setCurrentTime().

Note
You can bind other properties to currentTime, but it is not recommended setting bindings to it. As animation progresses, the currentTime is updated automatically, which cancels its bindings.

By default, this property contains a value of 0.

Definition at line 24 of file qtimeline.h.

◆ direction

QTimeLine::direction
readwrite

the direction of the timeline when QTimeLine is in \l Running state.

This direction indicates whether the time moves from 0 towards the timeline duration, or from the value of the duration and towards 0 after start() has been called.

Any binding of direction will be removed not only by setDirection(), but also by toggleDirection().

By default, this property is set to \l Forward.

Definition at line 25 of file qtimeline.h.

Referenced by setDirection().

◆ duration

QTimeLine::duration
readwrite

the total duration of the timeline in milliseconds.

By default, this value is 1000 (i.e., 1 second), but you can change this by either passing a duration to QTimeLine's constructor, or by calling setDuration(). The duration must be larger than 0.

Note
Changing the duration does not cause the current time to be reset to zero or the new duration. You also need to call setCurrentTime() with the desired value.

Definition at line 21 of file qtimeline.h.

Referenced by QTimeLine(), and setDuration().

◆ easingCurve

QTimeLine::easingCurve
readwrite
Since
4.6

Specifies the easing curve that the timeline will use. If valueForTime() is reimplemented, this value is ignored.

See also
valueForTime()

Definition at line 27 of file qtimeline.h.

◆ loopCount

QTimeLine::loopCount
readwrite

the number of times the timeline should loop before it's finished.

A loop count of 0 means that the timeline will loop forever.

By default, this property contains a value of 1.

Definition at line 26 of file qtimeline.h.

◆ updateInterval

QTimeLine::updateInterval
readwrite

the time in milliseconds between each time QTimeLine updates its current time.

When updating the current time, QTimeLine will emit valueChanged() if the current value changed, and frameChanged() if the frame changed.

By default, the interval is 40 ms, which corresponds to a rate of 25 updates per second.

Definition at line 22 of file qtimeline.h.


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