| ID | ... | Creation date | 20 June 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | 5800 xpress muzic |
| Category | Qt for Symbian | Subcategory | Application |
| Keywords (APIs, classes, methods, functions): QGraphicsItem,QGraphicsItemAnimation |
As heading of this article specifies "Animation with Transformation" ,Here the stepping of the Graphics Item and the rotation is observed.
A new coordinates for the graphics item is taken while executing through the loop and the item is shifted to that coordinate as well as rotated to a specific angle.
Name of classes used:
QGraphicsItem-Base class for all graphical items
QGraphicsItemAnimation-Provides simple animation support
text->setZValue(5.0);
animation->setRotationAt(i / 300.0, i);
#include <QtGui/QApplication>
#include "animation.h"
#include<QGraphicsItemAnimation>
#include<QPointF>
#include<QTimeLine>
#include<QGraphicsItem>
#include<QGraphicsSimpleTextItem>
#include<QGraphicsScene>
#include<QGraphicsView>
#include<QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsItem *text = new QGraphicsSimpleTextItem("Viral");
text->setAcceptDrops(1);
//text->setOpacity(0.0);
text->setAcceptHoverEvents(true);
text->setZValue(5.0);
QHBoxLayout *lay=new QHBoxLayout();
QTimeLine *timer = new QTimeLine(5000);
timer->setFrameRange(0, 100);
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation();
animation->setItem(text);
animation->setTimeLine(timer);
int i;
for (i = 0; i <= 250; ++i)//getting the coordinates
animation->setPosAt(i/250.0,QPointF(i, i));//positioning the graphicsItem
animation->setRotationAt(i / 300.0, i);//rotation of graphicsItem.
QGraphicsScene *scene = new QGraphicsScene();
scene->setSceneRect(0, 0, 250, 250);//rectuangular scene built
scene->addItem(text);
QGraphicsView *view = new QGraphicsView(scene);
view->show();
timer->start();//start timer to view animation
return a.exec();
}
No related wiki articles found