lundi 23 février 2015

QGraphicsView freezes when zooming under Win32

I use QGraphicsView and QGraphicsScene to display a map - a lot of object (lines, images, polygons, etc). I implemented zooming the view this way:



...
void MapView::wheelEvent( QWheelEvent *pEvent )
{
if ( pEvent->modifiers() & Qt::ControlModifier )
{
if ( pEvent->delta() > 0 )
zoomIn();
else
zoomOut();
pEvent->accept();
}
else
{
QGraphicsView::wheelEvent( pEvent );
}
}
...
void MapView::zoomIn( int nValue )
{
m_dZoom = ( nValue == -1 ) ? qMin( ( m_dZoom + m_dZoomStep ), m_dZoomMax ) : qMin( ( m_dZoom + qreal( nValue ) ), m_dZoomMax );
setupTransform();
}

void MapView::zoomOut( int nValue )
{
m_dZoom = ( nValue == -1 ) ? qMax( ( m_dZoom - m_dZoomStep ), m_dZoomMin ) : qMax( ( m_dZoom - qreal( nValue ) ), m_dZoomMin );
setupTransform();
}
...
void MapView::setupTransform()
{
QTransform t = transform();
t.reset();
qreal dScale = qPow( qreal( 2 ), ( m_dZoom - ( m_dZoomMax / 4 ) ) / qreal( 50 ) );
t.scale( dScale, dScale );
setTransform( t );
emit onZoomChanged( m_dZoom );
}
...


When I run application on Linux (CentOS 6.3, Qt 4.8) - zooming the view runs very good (smoothly). But when I run it on Windows (Windows 7 32bit, Qt 5.4) zoomig the view freezes - I constanly rotate the mouse wheel with no effect (no zooming, the view is not responding), and after a second or two later the view starts responding again. When this happens current zoom position turned out to be correctly set - it seems like the view were zooming but not updating the picture. The problem occurs with different zoom values and scroll positions, but always when the view is going to crop map objects (paths). Do you have any ideas how to fix that problem, or am I doing something wrong? Thank you very much in advance.


Aucun commentaire:

Enregistrer un commentaire