SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Qt 
Animation 
William.L 2010-05-19 
wiliwe@gmail.com
Outline 
 What is animation? 
 Timer 
 Timeline 
 Animation Framework 
 State Machine Framework 
 GraphicsView Framework
What is animation? 
 A series of pictures, each of which is shown for a 
fixed period
Timer (1/2) 
 Class – QTimer 
 Provides repetitive and single-shot timers 
 Emit the timeout() signal at constant intervals. 
 Usage 
 Create a QTimer 
 Connect its timeout() signal to the appropriate slots 
 Call start() with constant interval(in millisecond) parameter 
 From then on it will emit the timeout() signal at constant intervals. 
QTimer *timer = new QTimer(this); 
connect(timer, SIGNAL(timeout()), 
this, SLOT(doSomethingWhenTimeout())); 
timer-start(1000);
Timer (2/2) 
 Example 
 Timer-Button 
 A QPushButton moving between two points
Timeline (1/3) 
 Class – QTimeLine 
 Introduced in Qt 4.2 
 Most commonly used to animate a GUI control by calling 
a slot periodically. 
 Usage 
 Construct a QTimeLine object with duration value in 
milliseconds 
 The duration describes for how long the animation will run. 
 Set a suitable frame range by calling setFrameRange(). 
 Connect the frameChanged() signal to a suitable slot in the 
widget you wish to animate. 
 Ex : call setValue() in QProgressBar 
 Finally calling start(), QTimeLine will enter Running state 
 When done, QTimeLine enters NotRunning state, and emits 
finished().
Timeline (2/3) 
 Usage 
// Construct a 1-second(1000ms) timeline with a frame range of 0 - 100 
QTimeLine *timeLine = new QTimeLine (1000, Parent); 
timeLine-setFrameRange (0, 100); 
connect ( timeLine, SIGNAL(frameChanged(int)), 
widget, SLOT(Widget-Slot()) );
Timeline (3/3) 
 Other Methods 
 setLoopCount() 
 Holds the number of times the timeline should loop before it's 
finished. 
 0 means that the timeline will loop forever. 
 setUpdateInterval() 
 Holds the time in milliseconds between each time QTimeLine 
updates its current time 
 Default is 40ms (e.g. 25 frames per second) 
 setCurveShape() 
 Holds the shape of the timeline curve (how the timeline’s velocity 
change) 
 Default is EaseInOutCurve 
 Example 
 Timeline-Progressbar 
 Use timeline to increase the progress of the progress bar.
Animation Framework (1/5) 
 Introduced in 4.6 
 Part of the Kinetic project 
 Makes it easy to animate QObjects, including QWidgets, 
by allowing Qt properties to be animated. 
 Animations are controlled using Easing Curves and can 
be grouped together.
Animation Framework (2/5) 
 Perform animation of a Qt property (color, size, 
location, etc.) 
 QPropertyAnimation class 
 Containers for animating animations together 
 QSequentialAnimationGroup class 
 Contains animations are animating in sequence 
 QParallelAnimationGroup class 
 Contains animations are animating in parallel
Animation Framework (3/5) 
 Usage 
 Create a widget instance wanted to be animated. 
 Create a QPropertyAnimation instance passed widget instance 
and the widget’s property name wanted to be animated 
 Set animation duration 
 Set animated widget’s star/end property value through 
QPropertyAnimation methods, setStartValue() / setEndValue() 
 Call QPropertyAnimation’s start() method to start animating 
QPropertyAnimation *animation = new QPropertyAnimation(Widget, geometry); 
animation-setDuration(10000); // 10 seconds 
animation-setStartValue(QRect(250, 250, 100, 30)); 
animation-setEndValue(QRect(500, 450, 100, 30)); 
animation-start();
Animation Framework (4/5) 
 Fine Control 
 setKeyValueAt (step, value) 
 Creates a key frame at the given step with the given value. The given 
step must be in the range 0 to 1. 
QPropertyAnimation *animation = new QPropertyAnimation(Widget, geometry); 
animation-setDuration(10000); // 10 seconds 
animation.setKeyValueAt(0, QRect(250, 250, 100, 30)); 
animation.setKeyValueAt(0.25, QRect(250, 450, 100, 30)); 
animation.setKeyValueAt(0.5, QRect(500, 450, 100, 30)); 
animation.setKeyValueAt(0.75, QRect(500, 250, 100, 30)); 
animation.setKeyValueAt(1, QRect(250, 250, 100, 30)); 
animation-start();
Animation Framework (5/5) 
 Example 
 AnimFmwk-BounceEasyCurve-ParalSequ 
 Three buttons animating in sequential and parallel animations 
with easing curve 
 AnimFmwk-SetKeyValue 
 An animating button controlled by setKeyValueAt()
Qt State Machine Framework (1/7) 
 Classes – QStateMachine, QState, QFinalState, 
QSignalTransition 
 For creating and executing state graphs. 
 Provides an API and execution model that can be used 
to effectively embed the elements and semantics of 
statecharts in Qt applications. 
 Qt's event system is used to drive the state machines. 
 The animation framework also plugs into the new Qt 
state machine by allowing an animation to be played 
when transitions are triggered.
Qt State Machine Framework (2/7) 
 Components 
 QStateMachine 
 Manages a set of states and transitions 
 Hierarchical 
 Use the addState() function to add a top-level state(QState) to the 
state machine. 
 Before the machine can be started, use setInitialState() method to 
set the initial state 
 Call start() method to start the state machine 
 The started() signal is emitted when the initial state is entered 
 Call stop() to stop the state machine explicitly 
S1 
S1-1 S1-2 
S2
Qt State Machine Framework (3/7) 
 Components 
 QState 
 Represents a general-purpose state for QStateMachine 
 Can have child states 
 Can have transitions to other states 
 Use addTransition(sender,signal,target-state) method to add a 
transition, this will return a QSignalTransition object 
 Call addAnimation() of the returned QSignalTransition object and 
pass a QPropertyAnimation object to create a transition 
animation 
 QFinalState 
 Represents a final state 
 Used to communicate that a QStateMachine has finished its work 
 finished() signal will be emitted when entering the final state
Qt State Machine Framework (4/7) 
 Components 
 QSignalTransition 
 Provides a transition based on a Qt signal.
Qt State Machine Framework (5/7)
Qt State Machine Framework (6/7) 
 Usage 
QPushButton button(StateMachine Button); 
button.show(); 
QStateMachine machine; 
QState *state1 = new QState(); 
state1-assignProperty(button, geometry, QRect(200, 200, 100, 100)); 
QState *state2 = new QState(); 
state2-assignProperty(button, geometry, QRect(450, 450, 100, 100)); 
QFinalState *state3 = new QFinalState(); 
QSignalTransition *transition1 = state1-addTransition(button, SIGNAL(clicked()), state2); 
transition1-addAnimation(new QPropertyAnimation(button, geometry)); 
state2-addTransition(button, SIGNAL(clicked()), state3); 
machine.addState(state1); 
machine.addState(state2); 
machine.addState(state3); 
QObject::connect(machine, SIGNAL(finished()),QApplication::instance(), SLOT(quit())); 
machine.setInitialState(state1); 
machine.start();
Qt State Machine Framework (7/7) 
 Example 
 StateMachine-AnimButton 
 A QPushButton moves and changes its states when it is 
pressed. When reaching final state, the application will quit.
GraphicsView Framework (1/8) 
 Introduced in Qt 4.2 
 Replaced its predecessor, QCanvas 
 Item-based 
 Provides 
 A surface(scene) for managing and interacting with a large 
number of custom-made 2D graphical items 
 A view widget for visualizing the items, with support for zooming 
and rotation. 
 Items are varying geometric shapes(rectangle, line, circle, etc.)
GraphicsView Framework (2/8) 
Scene(Canvas) 
Line item 
Text item 
Rectangle item 
View 
Vertical 
Scrollbar 
Thumb 
Horizontal Scrollbar 
Thumb 
Ellipse 
item 
The dash-line 
rectangle is the 
visible area to 
human
GraphicsView Framework (3/8) 
 Components 
 The Scene - QGraphicsScene 
 Serves as a container for QGraphicsItem objects 
 Manages a large number of items 
 Propagating events from QGraphicsView to each item 
 Managing item state, such as item selection and focus.
GraphicsView Framework (4/8) 
 Components 
 The View - QGraphicsView 
 Provides the view widget 
 To visualize the contents of a scene 
 It is a scroll area 
 Can attach several views to the same scene 
 provide several viewports into the same data set. 
 Receives input events from the keyboard and mouse, and translates 
these to scene events
GraphicsView Framework (5/8) 
 Components 
 The Item – QGraphicsItem 
 The base class for graphical items in a scene 
 Detect mouse events 
 Grab keyboard input focus 
 Drag  Drop 
 Grouping 
 Collision detection
GraphicsView Framework (6/8) 
 Comparison between GraphicsView 
framework and Clutter 
Clutter 
Stage 
GraphicsView 
Framework 
GraphicsScene 
The place where 
visual elements 
exist (canvas) 
Visual Element GraphicsItem Actor 
Represnetation 
Viewport GraphicsView Gtk_Clutter_Viewport
GraphicsView Framework (7/8) 
 Usage 
 Create a QGraphicsScene object 
 Add objects of QGraphicsItem to the QGraphicsScene object 
using addXXX() method, where “XXX” means the type of 
graphics item. 
 Create a QGraphicsView object and set the created 
QGraphicsScene object with the method setScene() 
 Finally, let QGraphicsView object be visible by calling show() 
method. Or add created QGraphicsView object to a 
QMainWindow object by calling setCentralWidget()
GraphicsView Framework (8/8) 
 Example 
 GrphView-SimpleAnim 
 Shows how scene/view/items work together and an animation 
that a rectangle graphic item moves and fades out.
Example Source Codes Download 
 The example codes for this slide (GitHub). 
 https://github.com/wiliwe/qt-animation-example.git 
 Using Git tool to download: 
git clone https://github.com/wiliwe/qt-animation-example.git
References 
 http://doc.qt.nokia.com/4.6/qtimer.html 
 http://doc.qt.nokia.com/4.6/qtimeline.html 
 http://doc.qt.nokia.com/4.6/qtimeline.html#CurveShape-enum 
 http://doc.qt.nokia.com/4.6/animation-overview.html 
 http://doc.qt.nokia.com/4.6/statemachine-api.html 
 http://doc.qt.nokia.com/4.6/graphicsview.html 
 http://doc.qt.nokia.com/4.6/qgraphicsscene.html 
 http://doc.qt.nokia.com/4.6/qgraphicsitem.html

Mais conteúdo relacionado

Mais procurados

QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentICS
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QMLAlan Uthoff
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QMLICS
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickICS
 
Lessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML DevicesLessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML DevicesICS
 
Software Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicSoftware Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicICS
 
Qt test framework
Qt test frameworkQt test framework
Qt test frameworkICS
 
Operasi aritmatika register mikroprosesor
Operasi aritmatika register mikroprosesor Operasi aritmatika register mikroprosesor
Operasi aritmatika register mikroprosesor syahrunfacrezy
 

Mais procurados (17)

QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI development
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QML
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QML
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
 
Lessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML DevicesLessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML Devices
 
What is RabbitMQ ?
What is RabbitMQ ?What is RabbitMQ ?
What is RabbitMQ ?
 
Software Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicSoftware Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business Logic
 
Fiber optic
Fiber opticFiber optic
Fiber optic
 
Qt programming-using-cpp
Qt programming-using-cppQt programming-using-cpp
Qt programming-using-cpp
 
Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1
 
Qt Qml
Qt QmlQt Qml
Qt Qml
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Operasi aritmatika register mikroprosesor
Operasi aritmatika register mikroprosesor Operasi aritmatika register mikroprosesor
Operasi aritmatika register mikroprosesor
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 

Destaque

Special Effects with Qt Graphics View
Special Effects with Qt Graphics ViewSpecial Effects with Qt Graphics View
Special Effects with Qt Graphics Viewaccount inactive
 
Creating Slick User Interfaces With Qt
Creating Slick User Interfaces With QtCreating Slick User Interfaces With Qt
Creating Slick User Interfaces With QtEspen Riskedal
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Softwareaccount inactive
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with QtAriya Hidayat
 
Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesWilliam Lee
 
Learn how to develop applications and UIs with Qt Commercial
Learn how to develop applications and UIs with Qt CommercialLearn how to develop applications and UIs with Qt Commercial
Learn how to develop applications and UIs with Qt CommercialQt Commercial, Digia
 
Android GDB Debugging (Chinese)
Android GDB Debugging (Chinese)Android GDB Debugging (Chinese)
Android GDB Debugging (Chinese)William Lee
 
Android Storage - StorageManager & OBB
Android Storage - StorageManager & OBBAndroid Storage - StorageManager & OBB
Android Storage - StorageManager & OBBWilliam Lee
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneBhavesh Shah
 
Android Storage - Internal and External Storages
Android Storage - Internal and External StoragesAndroid Storage - Internal and External Storages
Android Storage - Internal and External StoragesWilliam Lee
 
Introduction to SIP(Session Initiation Protocol)
Introduction to SIP(Session Initiation Protocol)Introduction to SIP(Session Initiation Protocol)
Introduction to SIP(Session Initiation Protocol)William Lee
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - VoldWilliam Lee
 

Destaque (15)

Special Effects with Qt Graphics View
Special Effects with Qt Graphics ViewSpecial Effects with Qt Graphics View
Special Effects with Qt Graphics View
 
Creating Slick User Interfaces With Qt
Creating Slick User Interfaces With QtCreating Slick User Interfaces With Qt
Creating Slick User Interfaces With Qt
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
 
Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP Languages
 
Learn how to develop applications and UIs with Qt Commercial
Learn how to develop applications and UIs with Qt CommercialLearn how to develop applications and UIs with Qt Commercial
Learn how to develop applications and UIs with Qt Commercial
 
Android GDB Debugging (Chinese)
Android GDB Debugging (Chinese)Android GDB Debugging (Chinese)
Android GDB Debugging (Chinese)
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
Android Storage - StorageManager & OBB
Android Storage - StorageManager & OBBAndroid Storage - StorageManager & OBB
Android Storage - StorageManager & OBB
 
MGCP Overview
MGCP OverviewMGCP Overview
MGCP Overview
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 
Android Storage - Internal and External Storages
Android Storage - Internal and External StoragesAndroid Storage - Internal and External Storages
Android Storage - Internal and External Storages
 
Introduction to SIP(Session Initiation Protocol)
Introduction to SIP(Session Initiation Protocol)Introduction to SIP(Session Initiation Protocol)
Introduction to SIP(Session Initiation Protocol)
 
MTP & PTP
MTP & PTPMTP & PTP
MTP & PTP
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
 

Semelhante a Qt Animation

Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2NokiaAppForum
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9Shih-Hsiang Lin
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & WebkitQT-day
 
The Ring programming language version 1.6 book - Part 67 of 189
The Ring programming language version 1.6 book - Part 67 of 189The Ring programming language version 1.6 book - Part 67 of 189
The Ring programming language version 1.6 book - Part 67 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 61 of 180
The Ring programming language version 1.5.1 book - Part 61 of 180The Ring programming language version 1.5.1 book - Part 61 of 180
The Ring programming language version 1.5.1 book - Part 61 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 76 of 212
The Ring programming language version 1.10 book - Part 76 of 212The Ring programming language version 1.10 book - Part 76 of 212
The Ring programming language version 1.10 book - Part 76 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.8 book - Part 71 of 202The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.8 book - Part 71 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.8 book - Part 67 of 202The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.8 book - Part 67 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 80 of 184
The Ring programming language version 1.5.3 book - Part 80 of 184The Ring programming language version 1.5.3 book - Part 80 of 184
The Ring programming language version 1.5.3 book - Part 80 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 45 of 84
The Ring programming language version 1.2 book - Part 45 of 84The Ring programming language version 1.2 book - Part 45 of 84
The Ring programming language version 1.2 book - Part 45 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.7 book - Part 65 of 196The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.7 book - Part 65 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 17 of 31
The Ring programming language version 1.4.1 book - Part 17 of 31The Ring programming language version 1.4.1 book - Part 17 of 31
The Ring programming language version 1.4.1 book - Part 17 of 31Mahmoud Samir Fayed
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and GraphicsAndreas Jakl
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinPeter Friese
 
The Ring programming language version 1.10 book - Part 82 of 212
The Ring programming language version 1.10 book - Part 82 of 212The Ring programming language version 1.10 book - Part 82 of 212
The Ring programming language version 1.10 book - Part 82 of 212Mahmoud Samir Fayed
 
Java agents are watching your ByteCode
Java agents are watching your ByteCodeJava agents are watching your ByteCode
Java agents are watching your ByteCodeRoman Tsypuk
 
The Ring programming language version 1.5.4 book - Part 64 of 185
The Ring programming language version 1.5.4 book - Part 64 of 185The Ring programming language version 1.5.4 book - Part 64 of 185
The Ring programming language version 1.5.4 book - Part 64 of 185Mahmoud Samir Fayed
 

Semelhante a Qt Animation (20)

State Machine Framework
State Machine FrameworkState Machine Framework
State Machine Framework
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & Webkit
 
The Ring programming language version 1.6 book - Part 67 of 189
The Ring programming language version 1.6 book - Part 67 of 189The Ring programming language version 1.6 book - Part 67 of 189
The Ring programming language version 1.6 book - Part 67 of 189
 
The Ring programming language version 1.5.1 book - Part 61 of 180
The Ring programming language version 1.5.1 book - Part 61 of 180The Ring programming language version 1.5.1 book - Part 61 of 180
The Ring programming language version 1.5.1 book - Part 61 of 180
 
The Ring programming language version 1.10 book - Part 76 of 212
The Ring programming language version 1.10 book - Part 76 of 212The Ring programming language version 1.10 book - Part 76 of 212
The Ring programming language version 1.10 book - Part 76 of 212
 
The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.8 book - Part 71 of 202The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.8 book - Part 71 of 202
 
The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.8 book - Part 67 of 202The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.8 book - Part 67 of 202
 
The Ring programming language version 1.5.3 book - Part 80 of 184
The Ring programming language version 1.5.3 book - Part 80 of 184The Ring programming language version 1.5.3 book - Part 80 of 184
The Ring programming language version 1.5.3 book - Part 80 of 184
 
The Ring programming language version 1.2 book - Part 45 of 84
The Ring programming language version 1.2 book - Part 45 of 84The Ring programming language version 1.2 book - Part 45 of 84
The Ring programming language version 1.2 book - Part 45 of 84
 
The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.7 book - Part 65 of 196The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.7 book - Part 65 of 196
 
The Ring programming language version 1.4.1 book - Part 17 of 31
The Ring programming language version 1.4.1 book - Part 17 of 31The Ring programming language version 1.4.1 book - Part 17 of 31
The Ring programming language version 1.4.1 book - Part 17 of 31
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & Xamarin
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
 
The Ring programming language version 1.10 book - Part 82 of 212
The Ring programming language version 1.10 book - Part 82 of 212The Ring programming language version 1.10 book - Part 82 of 212
The Ring programming language version 1.10 book - Part 82 of 212
 
Java agents are watching your ByteCode
Java agents are watching your ByteCodeJava agents are watching your ByteCode
Java agents are watching your ByteCode
 
The Ring programming language version 1.5.4 book - Part 64 of 185
The Ring programming language version 1.5.4 book - Part 64 of 185The Ring programming language version 1.5.4 book - Part 64 of 185
The Ring programming language version 1.5.4 book - Part 64 of 185
 

Mais de William Lee

Usage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on LinuxUsage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on LinuxWilliam Lee
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHPWilliam Lee
 
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5 Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5 William Lee
 
Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3William Lee
 
Viewing Android Source Files in Eclipse (Chinese)
Viewing Android Source Files in Eclipse  (Chinese)Viewing Android Source Files in Eclipse  (Chinese)
Viewing Android Source Files in Eclipse (Chinese)William Lee
 
Usage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency WalkerUsage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency WalkerWilliam Lee
 
Usage Note of PlayCap
Usage Note of PlayCapUsage Note of PlayCap
Usage Note of PlayCapWilliam Lee
 
Qt4 App - Sliding Window
Qt4 App - Sliding WindowQt4 App - Sliding Window
Qt4 App - Sliding WindowWilliam Lee
 
GTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App ChooserGTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App ChooserWilliam Lee
 
GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserWilliam Lee
 
Note of CGI and ASP
Note of CGI and ASPNote of CGI and ASP
Note of CGI and ASPWilliam Lee
 
Moblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) PluginMoblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) PluginWilliam Lee
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationWilliam Lee
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5William Lee
 
C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)William Lee
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web PageWilliam Lee
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 UsageWilliam Lee
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)William Lee
 
Study of Chromium OS
Study of Chromium OSStudy of Chromium OS
Study of Chromium OSWilliam Lee
 
GNOME GeoClue - The Geolocation Service in Gnome
GNOME GeoClue - The Geolocation Service in GnomeGNOME GeoClue - The Geolocation Service in Gnome
GNOME GeoClue - The Geolocation Service in GnomeWilliam Lee
 

Mais de William Lee (20)

Usage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on LinuxUsage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on Linux
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHP
 
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5 Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
 
Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3
 
Viewing Android Source Files in Eclipse (Chinese)
Viewing Android Source Files in Eclipse  (Chinese)Viewing Android Source Files in Eclipse  (Chinese)
Viewing Android Source Files in Eclipse (Chinese)
 
Usage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency WalkerUsage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency Walker
 
Usage Note of PlayCap
Usage Note of PlayCapUsage Note of PlayCap
Usage Note of PlayCap
 
Qt4 App - Sliding Window
Qt4 App - Sliding WindowQt4 App - Sliding Window
Qt4 App - Sliding Window
 
GTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App ChooserGTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App Chooser
 
GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon Chooser
 
Note of CGI and ASP
Note of CGI and ASPNote of CGI and ASP
Note of CGI and ASP
 
Moblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) PluginMoblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) Plugin
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log Rotation
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
 
C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web Page
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
 
Study of Chromium OS
Study of Chromium OSStudy of Chromium OS
Study of Chromium OS
 
GNOME GeoClue - The Geolocation Service in Gnome
GNOME GeoClue - The Geolocation Service in GnomeGNOME GeoClue - The Geolocation Service in Gnome
GNOME GeoClue - The Geolocation Service in Gnome
 

Último

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Qt Animation

  • 1. Qt Animation William.L 2010-05-19 wiliwe@gmail.com
  • 2. Outline What is animation? Timer Timeline Animation Framework State Machine Framework GraphicsView Framework
  • 3. What is animation? A series of pictures, each of which is shown for a fixed period
  • 4. Timer (1/2) Class – QTimer Provides repetitive and single-shot timers Emit the timeout() signal at constant intervals. Usage Create a QTimer Connect its timeout() signal to the appropriate slots Call start() with constant interval(in millisecond) parameter From then on it will emit the timeout() signal at constant intervals. QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(doSomethingWhenTimeout())); timer-start(1000);
  • 5. Timer (2/2) Example Timer-Button A QPushButton moving between two points
  • 6. Timeline (1/3) Class – QTimeLine Introduced in Qt 4.2 Most commonly used to animate a GUI control by calling a slot periodically. Usage Construct a QTimeLine object with duration value in milliseconds The duration describes for how long the animation will run. Set a suitable frame range by calling setFrameRange(). Connect the frameChanged() signal to a suitable slot in the widget you wish to animate. Ex : call setValue() in QProgressBar Finally calling start(), QTimeLine will enter Running state When done, QTimeLine enters NotRunning state, and emits finished().
  • 7. Timeline (2/3) Usage // Construct a 1-second(1000ms) timeline with a frame range of 0 - 100 QTimeLine *timeLine = new QTimeLine (1000, Parent); timeLine-setFrameRange (0, 100); connect ( timeLine, SIGNAL(frameChanged(int)), widget, SLOT(Widget-Slot()) );
  • 8. Timeline (3/3) Other Methods setLoopCount() Holds the number of times the timeline should loop before it's finished. 0 means that the timeline will loop forever. setUpdateInterval() Holds the time in milliseconds between each time QTimeLine updates its current time Default is 40ms (e.g. 25 frames per second) setCurveShape() Holds the shape of the timeline curve (how the timeline’s velocity change) Default is EaseInOutCurve Example Timeline-Progressbar Use timeline to increase the progress of the progress bar.
  • 9. Animation Framework (1/5) Introduced in 4.6 Part of the Kinetic project Makes it easy to animate QObjects, including QWidgets, by allowing Qt properties to be animated. Animations are controlled using Easing Curves and can be grouped together.
  • 10. Animation Framework (2/5) Perform animation of a Qt property (color, size, location, etc.) QPropertyAnimation class Containers for animating animations together QSequentialAnimationGroup class Contains animations are animating in sequence QParallelAnimationGroup class Contains animations are animating in parallel
  • 11. Animation Framework (3/5) Usage Create a widget instance wanted to be animated. Create a QPropertyAnimation instance passed widget instance and the widget’s property name wanted to be animated Set animation duration Set animated widget’s star/end property value through QPropertyAnimation methods, setStartValue() / setEndValue() Call QPropertyAnimation’s start() method to start animating QPropertyAnimation *animation = new QPropertyAnimation(Widget, geometry); animation-setDuration(10000); // 10 seconds animation-setStartValue(QRect(250, 250, 100, 30)); animation-setEndValue(QRect(500, 450, 100, 30)); animation-start();
  • 12. Animation Framework (4/5) Fine Control setKeyValueAt (step, value) Creates a key frame at the given step with the given value. The given step must be in the range 0 to 1. QPropertyAnimation *animation = new QPropertyAnimation(Widget, geometry); animation-setDuration(10000); // 10 seconds animation.setKeyValueAt(0, QRect(250, 250, 100, 30)); animation.setKeyValueAt(0.25, QRect(250, 450, 100, 30)); animation.setKeyValueAt(0.5, QRect(500, 450, 100, 30)); animation.setKeyValueAt(0.75, QRect(500, 250, 100, 30)); animation.setKeyValueAt(1, QRect(250, 250, 100, 30)); animation-start();
  • 13. Animation Framework (5/5) Example AnimFmwk-BounceEasyCurve-ParalSequ Three buttons animating in sequential and parallel animations with easing curve AnimFmwk-SetKeyValue An animating button controlled by setKeyValueAt()
  • 14. Qt State Machine Framework (1/7) Classes – QStateMachine, QState, QFinalState, QSignalTransition For creating and executing state graphs. Provides an API and execution model that can be used to effectively embed the elements and semantics of statecharts in Qt applications. Qt's event system is used to drive the state machines. The animation framework also plugs into the new Qt state machine by allowing an animation to be played when transitions are triggered.
  • 15. Qt State Machine Framework (2/7) Components QStateMachine Manages a set of states and transitions Hierarchical Use the addState() function to add a top-level state(QState) to the state machine. Before the machine can be started, use setInitialState() method to set the initial state Call start() method to start the state machine The started() signal is emitted when the initial state is entered Call stop() to stop the state machine explicitly S1 S1-1 S1-2 S2
  • 16. Qt State Machine Framework (3/7) Components QState Represents a general-purpose state for QStateMachine Can have child states Can have transitions to other states Use addTransition(sender,signal,target-state) method to add a transition, this will return a QSignalTransition object Call addAnimation() of the returned QSignalTransition object and pass a QPropertyAnimation object to create a transition animation QFinalState Represents a final state Used to communicate that a QStateMachine has finished its work finished() signal will be emitted when entering the final state
  • 17. Qt State Machine Framework (4/7) Components QSignalTransition Provides a transition based on a Qt signal.
  • 18. Qt State Machine Framework (5/7)
  • 19. Qt State Machine Framework (6/7) Usage QPushButton button(StateMachine Button); button.show(); QStateMachine machine; QState *state1 = new QState(); state1-assignProperty(button, geometry, QRect(200, 200, 100, 100)); QState *state2 = new QState(); state2-assignProperty(button, geometry, QRect(450, 450, 100, 100)); QFinalState *state3 = new QFinalState(); QSignalTransition *transition1 = state1-addTransition(button, SIGNAL(clicked()), state2); transition1-addAnimation(new QPropertyAnimation(button, geometry)); state2-addTransition(button, SIGNAL(clicked()), state3); machine.addState(state1); machine.addState(state2); machine.addState(state3); QObject::connect(machine, SIGNAL(finished()),QApplication::instance(), SLOT(quit())); machine.setInitialState(state1); machine.start();
  • 20. Qt State Machine Framework (7/7) Example StateMachine-AnimButton A QPushButton moves and changes its states when it is pressed. When reaching final state, the application will quit.
  • 21. GraphicsView Framework (1/8) Introduced in Qt 4.2 Replaced its predecessor, QCanvas Item-based Provides A surface(scene) for managing and interacting with a large number of custom-made 2D graphical items A view widget for visualizing the items, with support for zooming and rotation. Items are varying geometric shapes(rectangle, line, circle, etc.)
  • 22. GraphicsView Framework (2/8) Scene(Canvas) Line item Text item Rectangle item View Vertical Scrollbar Thumb Horizontal Scrollbar Thumb Ellipse item The dash-line rectangle is the visible area to human
  • 23. GraphicsView Framework (3/8) Components The Scene - QGraphicsScene Serves as a container for QGraphicsItem objects Manages a large number of items Propagating events from QGraphicsView to each item Managing item state, such as item selection and focus.
  • 24. GraphicsView Framework (4/8) Components The View - QGraphicsView Provides the view widget To visualize the contents of a scene It is a scroll area Can attach several views to the same scene provide several viewports into the same data set. Receives input events from the keyboard and mouse, and translates these to scene events
  • 25. GraphicsView Framework (5/8) Components The Item – QGraphicsItem The base class for graphical items in a scene Detect mouse events Grab keyboard input focus Drag Drop Grouping Collision detection
  • 26. GraphicsView Framework (6/8) Comparison between GraphicsView framework and Clutter Clutter Stage GraphicsView Framework GraphicsScene The place where visual elements exist (canvas) Visual Element GraphicsItem Actor Represnetation Viewport GraphicsView Gtk_Clutter_Viewport
  • 27. GraphicsView Framework (7/8) Usage Create a QGraphicsScene object Add objects of QGraphicsItem to the QGraphicsScene object using addXXX() method, where “XXX” means the type of graphics item. Create a QGraphicsView object and set the created QGraphicsScene object with the method setScene() Finally, let QGraphicsView object be visible by calling show() method. Or add created QGraphicsView object to a QMainWindow object by calling setCentralWidget()
  • 28. GraphicsView Framework (8/8) Example GrphView-SimpleAnim Shows how scene/view/items work together and an animation that a rectangle graphic item moves and fades out.
  • 29. Example Source Codes Download The example codes for this slide (GitHub). https://github.com/wiliwe/qt-animation-example.git Using Git tool to download: git clone https://github.com/wiliwe/qt-animation-example.git
  • 30. References http://doc.qt.nokia.com/4.6/qtimer.html http://doc.qt.nokia.com/4.6/qtimeline.html http://doc.qt.nokia.com/4.6/qtimeline.html#CurveShape-enum http://doc.qt.nokia.com/4.6/animation-overview.html http://doc.qt.nokia.com/4.6/statemachine-api.html http://doc.qt.nokia.com/4.6/graphicsview.html http://doc.qt.nokia.com/4.6/qgraphicsscene.html http://doc.qt.nokia.com/4.6/qgraphicsitem.html