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
qtimeline.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QTIMELINE_H
6#define QTIMELINE_H
7
8#include <QtCore/qglobal.h>
9
11
12#include <QtCore/qeasingcurve.h>
13#include <QtCore/qobject.h>
14
15QT_BEGIN_NAMESPACE
16
17
18class QTimeLinePrivate;
19class Q_CORE_EXPORT QTimeLine : public QObject
20{
21 Q_OBJECT
22 Q_PROPERTY(int duration READ duration WRITE setDuration BINDABLE bindableDuration)
23 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
24 BINDABLE bindableUpdateInterval)
25 Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime BINDABLE bindableCurrentTime)
26 Q_PROPERTY(Direction direction READ direction WRITE setDirection BINDABLE bindableDirection)
27 Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount BINDABLE bindableLoopCount)
28 Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve
29 BINDABLE bindableEasingCurve)
30public:
31 enum State {
32 NotRunning,
33 Paused,
34 Running
35 };
36 enum Direction {
37 Forward,
38 Backward
39 };
40
41 explicit QTimeLine(int duration = 1000, QObject *parent = nullptr);
42 virtual ~QTimeLine();
43
44 State state() const;
45
46 int loopCount() const;
47 void setLoopCount(int count);
48 QBindable<int> bindableLoopCount();
49
50 Direction direction() const;
51 void setDirection(Direction direction);
52 QBindable<Direction> bindableDirection();
53
54 int duration() const;
55 void setDuration(int duration);
56 QBindable<int> bindableDuration();
57
58 int startFrame() const;
59 void setStartFrame(int frame);
60 int endFrame() const;
61 void setEndFrame(int frame);
62 void setFrameRange(int startFrame, int endFrame);
63
64 int updateInterval() const;
65 void setUpdateInterval(int interval);
66 QBindable<int> bindableUpdateInterval();
67
68 QEasingCurve easingCurve() const;
69 void setEasingCurve(const QEasingCurve &curve);
70 QBindable<QEasingCurve> bindableEasingCurve();
71
72 int currentTime() const;
73 QBindable<int> bindableCurrentTime();
74 int currentFrame() const;
75 qreal currentValue() const;
76
77 int frameForTime(int msec) const;
78 virtual qreal valueForTime(int msec) const;
79
80public Q_SLOTS:
81 void start();
82 void resume();
83 void stop();
84 void setPaused(bool paused);
85 void setCurrentTime(int msec);
86 void toggleDirection();
87
88Q_SIGNALS:
89 void valueChanged(qreal x, QPrivateSignal);
90 void frameChanged(int, QPrivateSignal);
91 void stateChanged(QTimeLine::State newState, QPrivateSignal);
92 void finished(QPrivateSignal);
93
94protected:
95 void timerEvent(QTimerEvent *event) override;
96
97private:
98 Q_DISABLE_COPY(QTimeLine)
99 Q_DECLARE_PRIVATE(QTimeLine)
100};
101
102QT_END_NAMESPACE
103
104#endif
\inmodule QtCore
Definition qtimeline.h:20
QT_REQUIRE_CONFIG(easingcurve)