You Are Here:

Community: Wiki

This page was last modified on 30 October 2009, at 22:46.

Animation with Transformation in Qt for Symbian

From Forum Nokia Wiki



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

Overview

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

Preconditions

Property

  • Sets the Z-value, or the elevation, of the item, to z. The elevation decides the stacking order of sibling (neighboring) items
text->setZValue(5.0);
  • Sets the rotation of the item at the given step value to the angle specified.
animation->setRotationAt(i / 300.0, i);

SourceCode

main.cpp

#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();
}

ScreenShot

Image:Animation001.jpg

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ