|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.core.QTimeLine
public class QTimeLine
The QTimeLine
class provides a timeline for controlling animations. 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 (e.g., 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); timeLine.setFrameRange(0, 100); timeLine.frameChanged.connect(progressBar, "setValue(int)"); // Clicking the push button will start the progress bar animation pushButton = new QPushButton(tr("Start animation"), this); pushButton.clicked.connect(timeLine, "start()"); // ...You can also use
QTimeLine
with the Graphics View framework for animations. The QGraphicsItemAnimation
class implements animation of QGraphicsItems
with a timeline. By default the timeline runs once, from the beginning and towards the 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 setCurveShape()
. By default, QTimeLine
uses the EaseInOut curve shape, 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 curveShape
property is ignored.
QProgressBar
, QProgressDialog
, and QGraphicsItemAnimation
.
Nested Class Summary | |
---|---|
static class |
QTimeLine.CurveShape
This enum describes the default shape of QTimeLine 's value curve. |
static class |
QTimeLine.Direction
This enum describes the direction of the timeline when in Running state. |
static class |
QTimeLine.State
This enum describes the state of a window. |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal0 |
finished
This signal is emitted when QTimeLine finishes (i.e., reaches the end of its time line), and does not loop. |
QSignalEmitter.Signal1 |
frameChanged
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
stateChanged
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
valueChanged
This signal takes 1 generic argument(s). |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QTimeLine()
Constructs a timeline with a duration of duration milliseconds. |
|
QTimeLine(int duration)
Constructs a timeline with a duration of duration milliseconds. |
|
QTimeLine(int duration,
QObject parent)
Constructs a timeline with a duration of duration milliseconds. |
Method Summary | |
---|---|
int |
currentFrame()
Returns the frame corresponding to the current time. |
int |
currentTime()
This property holds the current time of the time line. |
double |
currentValue()
Returns the value corresponding to the current time. |
QTimeLine.CurveShape |
curveShape()
This property holds the shape of the timeline curve. |
QTimeLine.Direction |
direction()
This property holds the direction of the timeline when QTimeLine is in Running state.. |
int |
duration()
This property holds the total duration of the timeline in milliseconds. |
int |
endFrame()
Returns the end frame, which is the frame corresponding to the end of the timeline (i. |
int |
frameForTime(int msec)
Returns the frame corresponding to the time msec. |
int |
loopCount()
This property holds the number of times the timeline should loop before it's finished. |
void |
resume()
Resumes the timeline from the current time. |
void |
setCurrentTime(int msec)
This property holds the current time of the time line. |
void |
setCurveShape(QTimeLine.CurveShape shape)
This property holds the shape of the timeline curve. |
void |
setDirection(QTimeLine.Direction direction)
This property holds the direction of the timeline when QTimeLine is in Running state.. |
void |
setDuration(int duration)
This property holds the total duration of the timeline in milliseconds. |
void |
setEndFrame(int frame)
Sets the end frame, which is the frame corresponding to the end of the timeline (i. |
void |
setFrameRange(int startFrame,
int endFrame)
Sets the timeline's frame counter to start at startFrame, and end and endFrame. |
void |
setLoopCount(int count)
This property holds the number of times the timeline should loop before it's finished. |
void |
setPaused(boolean paused)
If paused is true, the timeline is paused, causing QTimeLine to enter Paused state. |
void |
setStartFrame(int frame)
Sets the start frame, which is the frame corresponding to the start of the timeline (i. |
void |
setUpdateInterval(int interval)
This property holds the time in milliseconds between each time QTimeLine updates its current time.. |
void |
start()
Starts the timeline. |
int |
startFrame()
Returns the start frame, which is the frame corresponding to the start of the timeline (i. |
QTimeLine.State |
state()
Returns the state of the timeline. |
void |
stop()
Stops the timeline, causing QTimeLine to enter NotRunning state. |
void |
toggleDirection()
Toggles the direction of the timeline. |
int |
updateInterval()
This property holds the time in milliseconds between each time QTimeLine updates its current time.. |
double |
valueForTime(int msec)
Returns the timeline value for the time msec. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal0 finished
QTimeLine
finishes (i.e., reaches the end of its time line), and does not loop.
public final QSignalEmitter.Signal1 frameChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: frame)>:
QTimeLine
emits this signal at regular intervals when in Running
state, but only if the current frame changes. frame is the current frame number.
QTimeLine::setFrameRange()
, and QTimeLine::updateInterval
.
public final QSignalEmitter.Signal1 stateChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QTimeLine$State(named: newState)>:
This signal is emitted whenever QTimeLine
's state changes. The new state is newState.
public final QSignalEmitter.Signal1 valueChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Double(named: value)>:
QTimeLine
emits this signal at regular intervals when in Running
state, but only if the current value changes. value is the current value. value is a number between 0.0 and 1.0
QTimeLine::setDuration()
, QTimeLine::valueForTime()
, and QTimeLine::updateInterval
.
Constructor Detail |
---|
public QTimeLine(int duration)
QObject
's constructor. The default duration is 1000 milliseconds.
public QTimeLine()
QObject
's constructor. The default duration is 1000 milliseconds.
public QTimeLine(int duration, QObject parent)
QObject
's constructor. The default duration is 1000 milliseconds.
Method Detail |
---|
public final int currentFrame()
currentTime()
, frameForTime()
, and setFrameRange()
.
public final int currentTime()
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()
.
public final double currentValue()
valueForTime()
, and currentFrame()
.
public final QTimeLine.CurveShape curveShape()
valueForTime()
. If you have reimplemented valueForTime()
, this value is ignored.
valueForTime()
.
public final QTimeLine.Direction direction()
QTimeLine
is in 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.
public final int duration()
QTimeLine
's constructor, or by calling setDuration()
. The duration must be larger than 0.
public final int endFrame()
setEndFrame()
, and setFrameRange()
.
public final int frameForTime(int msec)
valueForTime()
. valueForTime()
, and setFrameRange()
.
public final int loopCount()
public final void resume()
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 is resumes.
start()
, updateInterval()
, frameChanged()
, and valueChanged()
.
public final void setCurrentTime(int msec)
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()
.
public final void setCurveShape(QTimeLine.CurveShape shape)
valueForTime()
. If you have reimplemented valueForTime()
, this value is ignored.
valueForTime()
.
public final void setDirection(QTimeLine.Direction direction)
QTimeLine
is in 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.
public final void setDuration(int duration)
QTimeLine
's constructor, or by calling setDuration()
. The duration must be larger than 0.
public final void setEndFrame(int frame)
endFrame()
, startFrame()
, and setFrameRange()
.
public final void setFrameRange(int startFrame, int endFrame)
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.
startFrame()
, endFrame()
, start()
, and currentFrame()
.
public final void setLoopCount(int count)
public final void setPaused(boolean paused)
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. state()
, and start()
.
public final void setStartFrame(int frame)
startFrame()
, endFrame()
, and setFrameRange()
.
public final void setUpdateInterval(int interval)
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.
public final void start()
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()
. If you want to resume a stopped timeline without restarting, you can call resume()
instead.
resume()
, updateInterval()
, frameChanged()
, and valueChanged()
.
public final int startFrame()
setStartFrame()
, and setFrameRange()
.
public final QTimeLine.State state()
start()
, setPaused()
, and stop()
.
public final void stop()
QTimeLine
to enter NotRunning
state. start()
.
public final void toggleDirection()
setDirection()
.
public final int updateInterval()
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.
public double valueForTime(int msec)
Reimplement this function to provide a custom curve shape for your timeline.
CurveShape
, and frameForTime()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |