hi Gopala,
thanks a lot for ur valuable help. i m able to make out the difference.now i want to zoom an item. i m able to do that but in zooming the item i want tht whatever part of that item i click, should be zoomed(obviously with the item itself) and displayed..
i m attaching some screen shots.
problem 1:
the initial execution is shot1.now when i m right clicking on the circle then its zooming as in shot2. but if i want to click on east south corner of the circle then tht part shd be seen on the view not the west north part as i have shown in shot3.. plz see to it..
{
if (event->buttons() & Qt::RightButton)
{
delta1+=0.2;
scale(delta1,delta1);
ensureVisible((event->pos()).x(),(event->pos()).y(),50,50,50,50);
//setPos((event->pos()).x(),(event->pos()).y());
}
else
//p1 = event->buttonDownScenePos(Qt::LeftButton);
}
QRectF Item
::boundingRect() const
path.addEllipse(5, 5, 50, 50);
return path; }
void Item::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->buttons() & Qt::RightButton)
{
delta1+=0.2;
scale(delta1,delta1);
ensureVisible((event->pos()).x(),(event->pos()).y(),50,50,50,50);
//setPos((event->pos()).x(),(event->pos()).y());
}
else
QGraphicsItem::mousePressEvent(event);
//p1 = event->buttonDownScenePos(Qt::LeftButton);
}
QRectF Item::boundingRect() const
{ return QRectF(0,0,60,60); }
QPainterPath Item::shape() const
{ QPainterPath path;
path.addEllipse(5, 5, 50, 50);
return path; }
To copy to clipboard, switch view to plain text mode
problem 2:
when i m clicking "draw" then i m getting shot4. but when i m moving different items like square,circle,line,coloured ellipse or QGraphicsTextItem("shuchi") then many times the other item which is not clicked also get moved. why????
void MainWindow::draw()
{
scene->addItem(line);
rect->setRect(60,60,90,90);
ellipse->setRect( 50, 50, 50, 50 );
text1 = new MyTextItem("Shuchi", 0, scene);
text1->setPos(150,150); }
void MainWindow::draw()
{
QGraphicsLineItem *line = new QGraphicsLineItem(10.0,10.0,50.0,50.0);
line->setFlag( QGraphicsItem::ItemIsMovable );
scene->addItem(line);
QGraphicsRectItem *rect = new QGraphicsRectItem(0, scene);
rect->setRect(60,60,90,90);
rect->setFlag( QGraphicsItem::ItemIsMovable );
QGraphicsEllipseItem *ellipse = new QGraphicsEllipseItem( 0, scene );
ellipse->setRect( 50, 50, 50, 50 );
ellipse->setFlag( QGraphicsItem::ItemIsMovable );
text1 = new MyTextItem("Shuchi", 0, scene);
text1->setPos(150,150); }
To copy to clipboard, switch view to plain text mode
shots.zip
Bookmarks