You Are Here:

Community: Wiki

This page was last modified on 1 November 2009, at 13:58.

Transformation of QGraphicsView

From Forum Nokia Wiki



ID ... Creation date 10 June 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices Creator IDE V 4.5 and Emulator
Category Qt for S60 Subcategory Application


Keywords (APIs, classes, methods, functions): QGraphicsScene,QGraphicsView

Overview

QGraphicsView supports the same affine transformations as QPainter does through QGraphicsView::setMatrix(). By applying a transformation to the view, you can easily add support for common navigation features such as zooming and rotating.

Classes used:

QGraphicsScene-Provides a surface for managing a large number of 2D graphical items

QGraphiceview-Provides a widget for displaying the contents of a QGraphicsScene.

Preconditions

Source Code

Header File

#ifndef TRANS_H
#define TRANS_H
 
#include <QtGui/QDialog>
#include "ui_trans.h"
#include<QGraphicsScene>
#include<QGraphicsView>
#include<QPushButton>
#include<QWidget>
#include<QHBoxLayout>
#include<QTextEdit>
#include<QVBoxLayout>
#include<QString>
 
class trans : public QDialog
{
Q_OBJECT
 
public:
trans(QWidget *parent = 0);
~trans();
 
private:
QGraphicsScene *scene;
QGraphicsView *view;
QVBoxLayout *lay;
QPushButton *but1;
QPushButton *but2;
QPushButton *but3;
QPushButton *but4;
QWidget *win;
QTextEdit *txt;
QVBoxLayout *vlay;
 
 
private slots:
void zoomIn(){view->scale(1.2, 1.2);}
void zoomOut(){ view->scale(1/1.2,1/1.2);}
void xhg();
void rotateLeft() { view->rotate(-90); }
void rotateRight() { view->rotate(90); }
 
};
#endif // TRANS_H

Cpp File

#include "trans.h"
#include "ui_trans.h"
 
trans::trans(QWidget *parent)
: QWidget(parent)
{
list=new QListWidget(this);
list->resize(0,0);
list1=new QListWidget(this);
lay=new QHBoxLayout(this);
list->addItem("Nokia");
list->addItem("Samsung");
list->addItem("Motorola");
list1->addItem("Nokia 6630");
list1->addItem("5800 Xpress Music");
list1->addItem("N96");
 
list->setSelectionMode(QAbstractItemView::SingleSelection);
list->setDragEnabled(true);
list->setDragDropMode(QAbstractItemView::InternalMove);
list->viewport()->setAcceptDrops(true);
 
list->setDropIndicatorShown(true);
 
list1->setSelectionMode(QAbstractItemView::SingleSelection);
list1->setDragEnabled(true);
list1->viewport()->setAcceptDrops(true);
 
list1->setDropIndicatorShown(true);
 
lay->addWidget(list);
lay->addWidget(list1);
setLayout(lay);
list->setStyleSheet("* { background-color:rgb(150,147,88);color:rgb(255,255,255); padding: 7px}}");
list1->setStyleSheet("* { background-color:rgb(150,140,70);color:rgb(255,255,255); padding: 7px}}");
resize(200,200);
showMaximized();
}
 
trans::~trans()
{
// No need to delete any object it has got a parent which is properly deleted.
}
void trans::xhg()
{
QString s3= txt->toPlainText();
 
scene->addText(s3);
scene->update();
view->show();
 
}

Screen shot

More about QGraphicView visit: QGraphicsView

Image:Traans001.jpg



[More about QGraphicView visit: QGraphicsView

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: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX 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