diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index f3f38a68acf1..b543d4d1bc43 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -691,7 +691,11 @@ QgsRectangle QgsMapCanvas::imageRect( const QImage &img, const QgsMapSettings &m const QgsMapToPixel &m2p = mapSettings.mapToPixel(); QgsPointXY topLeft = m2p.toMapCoordinates( 0, 0 ); Q_ASSERT( img.devicePixelRatio() == mapSettings.devicePixelRatio() ); +#if QT_VERSION >= 0x050600 double res = m2p.mapUnitsPerPixel() / img.devicePixelRatioF(); +#else + double res = m2p.mapUnitsPerPixel() / img.devicePixelRatio(); +#endif QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + img.width()*res, topLeft.y() - img.height()*res ); return rect; } diff --git a/src/gui/qgsmapcanvasmap.cpp b/src/gui/qgsmapcanvasmap.cpp index 0269cd3728ba..e47315498489 100644 --- a/src/gui/qgsmapcanvasmap.cpp +++ b/src/gui/qgsmapcanvasmap.cpp @@ -65,11 +65,20 @@ void QgsMapCanvasMap::paint( QPainter *painter ) int h = std::round( mItemSize.height() ) - 2; bool scale = false; - if ( mImage.size() != QSize( w, h )*mImage.devicePixelRatioF() ) +#if QT_VERSION >= 0x050600 + if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatioF() ) +#else + if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatio() ) +#endif { QgsDebugMsg( QStringLiteral( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ) +#if QT_VERSION >= 0x050600 .arg( mImage.width() / mImage.devicePixelRatioF() ) .arg( mImage.height() / mImage.devicePixelRatioF() ) +#else + .arg( mImage.width() / mImage.devicePixelRatio() ) + .arg( mImage.height() / mImage.devicePixelRatio() ) +#endif .arg( w ).arg( h ) ); // This happens on zoom events when ::paint is called before // the renderer has completed