wagmare
21st March 2013, 12:08
Hi Friends,
I made a QGraphicsView of size (0, 0, 1024, 1024)
and QGraphicsScene of size (0, 0, 2048, 2048)
i drawn some grid lines on the scene using
drawForeground(QPainter *painter, const QRectF &rect)
and now to make the scene to fit with the view
i used
View::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
}
and then i implemented zoom in the scene with
void View::wheelEvent(QWheelEvent *e)
{
qreal factor = pow((double)2, -e->delta() / 240.0);
zoom(factor);
}
void View::zoom(qreal factor)
{
scale(factor, factor);
}
this zooming is not working for enlarging .
if i remove the fitInView it allowing to zoom but scene looks bigger than view .
Please help me
Thanks in Advance
I made a QGraphicsView of size (0, 0, 1024, 1024)
and QGraphicsScene of size (0, 0, 2048, 2048)
i drawn some grid lines on the scene using
drawForeground(QPainter *painter, const QRectF &rect)
and now to make the scene to fit with the view
i used
View::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
}
and then i implemented zoom in the scene with
void View::wheelEvent(QWheelEvent *e)
{
qreal factor = pow((double)2, -e->delta() / 240.0);
zoom(factor);
}
void View::zoom(qreal factor)
{
scale(factor, factor);
}
this zooming is not working for enlarging .
if i remove the fitInView it allowing to zoom but scene looks bigger than view .
Please help me
Thanks in Advance