coderCPP1981
25th June 2008, 08:29
Hi ,
I am facing the problem with zooming functionality of QGraphicsView.
I have to draw images on QGraphicsView and for that I have used the following code.
QGraphicsScene *m_scene = new QGraphicsScene;
const QPixmap *pic = new QPixmap( "/home/bargi/aa.png" );
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem( pic );
m_scene->addItem(pixmapItem );
For creating View:
View::View( QWidget *parent )
: QGraphicsView( parent )
{
QGraphicsScene *m_scene = new QGraphicsScene;
setScene( m_scene );}
But the image was increasing its size on zoomIn and decreasing on zoom out.
I want that its size should remain constant.For this I have used some flags related to QGraphicsPixmapItem. The code is below:
pixmapItem->setFlag(QGraphicsItem::ItemIgnoresTransformations) ;
"ItemIgnoresTransformations" flag should ignore all the transformation applied on it like zoomIn or zoomOut.
But doing this lead to strange behavior, now when I zoomIn on image its hide to some extent on every click of ZoomIn and hide all at particular level.
I am not able to understand why this is happening.
I have attached the screenshot in which the images are shown at different zoom level.
In first u will see that images are drawn properly. In second and third you see the change that images are hiding on every zoomIn click.
In 4th image ,some images are partially hide.When I scroll the vertical or horizontal scroll bar they semi-hide images are shown properly.
I can't understand this behavior.
Also, when I comment "itemignoretransformation" it doesn't hide the images but increase there size which I don't want.
CAn any body help me in solving this problem????
Any queries are most welcome ??
Thanks :(
I am facing the problem with zooming functionality of QGraphicsView.
I have to draw images on QGraphicsView and for that I have used the following code.
QGraphicsScene *m_scene = new QGraphicsScene;
const QPixmap *pic = new QPixmap( "/home/bargi/aa.png" );
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem( pic );
m_scene->addItem(pixmapItem );
For creating View:
View::View( QWidget *parent )
: QGraphicsView( parent )
{
QGraphicsScene *m_scene = new QGraphicsScene;
setScene( m_scene );}
But the image was increasing its size on zoomIn and decreasing on zoom out.
I want that its size should remain constant.For this I have used some flags related to QGraphicsPixmapItem. The code is below:
pixmapItem->setFlag(QGraphicsItem::ItemIgnoresTransformations) ;
"ItemIgnoresTransformations" flag should ignore all the transformation applied on it like zoomIn or zoomOut.
But doing this lead to strange behavior, now when I zoomIn on image its hide to some extent on every click of ZoomIn and hide all at particular level.
I am not able to understand why this is happening.
I have attached the screenshot in which the images are shown at different zoom level.
In first u will see that images are drawn properly. In second and third you see the change that images are hiding on every zoomIn click.
In 4th image ,some images are partially hide.When I scroll the vertical or horizontal scroll bar they semi-hide images are shown properly.
I can't understand this behavior.
Also, when I comment "itemignoretransformation" it doesn't hide the images but increase there size which I don't want.
CAn any body help me in solving this problem????
Any queries are most welcome ??
Thanks :(