2
2
3
3
from .backend_cairo import cairo , FigureCanvasCairo , RendererCairo
4
4
from .backend_qt5 import QtCore , QtGui , _BackendQT5 , FigureCanvasQT
5
- from .qt_compat import QT_API
5
+ from .qt_compat import QT_API , _setDevicePixelRatioF
6
6
7
7
8
8
class FigureCanvasQTCairo (FigureCanvasQT , FigureCanvasCairo ):
@@ -19,8 +19,8 @@ def draw(self):
19
19
def paintEvent (self , event ):
20
20
self ._update_dpi ()
21
21
dpi_ratio = self ._dpi_ratio
22
- width = dpi_ratio * self .width ()
23
- height = dpi_ratio * self .height ()
22
+ width = int ( dpi_ratio * self .width () )
23
+ height = int ( dpi_ratio * self .height () )
24
24
if (width , height ) != self ._renderer .get_canvas_width_height ():
25
25
surface = cairo .ImageSurface (cairo .FORMAT_ARGB32 , width , height )
26
26
self ._renderer .set_ctx_from_surface (surface )
@@ -33,9 +33,7 @@ def paintEvent(self, event):
33
33
# QImage under PySide on Python 3.
34
34
if QT_API == 'PySide' :
35
35
ctypes .c_long .from_address (id (buf )).value = 1
36
- if hasattr (qimage , 'setDevicePixelRatio' ):
37
- # Not available on Qt4 or some older Qt5.
38
- qimage .setDevicePixelRatio (dpi_ratio )
36
+ _setDevicePixelRatioF (qimage , dpi_ratio )
39
37
painter = QtGui .QPainter (self )
40
38
painter .eraseRect (event .rect ())
41
39
painter .drawImage (0 , 0 , qimage )
0 commit comments