PDA

View Full Version : QGraphicsView::fitInView() problem on Windows



nileshsince1980
17th November 2009, 11:17
Hi All,

I have created application on Windows/Linux using QT 4.5.1 (Open Source). I have used QGraphicsView/Scene architecture to display Graphics items (rectangles etc). I have implemented zoom selection functionaliy. i.e. on Mouse selection, the zoom in the selected area using QGraphicsView::fitInView() function.
My code works find on Linux but on Windows XP it hangs/slows down after 2 consecutive zoom in operations.
Please tell me what could be the cause ?? Or any clue.

Thanks in advance.

Following is the functions from my code,

void MyGraphicsView::paintEvent(QPaintEvent * event)
{
QPaintEvent *newEvent = new QPaintEvent(event->region().boundingRect());
QGraphicsView::paintEvent(event);
delete newEvent;
}

void MyGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
QPainterPath path = scene()->selectionArea();
scene()->clearSelection();
fitInView(path.boundingRect(), Qt::KeepAspectRatio);
QGraphicsView::mouseReleaseEvent(event);
}

nileshsince1980
18th November 2009, 04:52
Hello All,

I have notices that same code works fine on Windows for QT 4.3.1 but not with QT 4.5.1.
I have also checked the updations/changes of in 4.5.1 version but not able to find much info. But in 4.5.0, QGraphicsView::fitInView() function has been improved for very small viewport. (see the link http://qt.nokia.com/developer/changes/changes-4.5.0

Can anybody tell me how to solve this problem ?