Skip to content

Commit 948c8ea

Browse files
committed
PyQt5: QPixmap.grabWidget --> QWidget.grab
1 parent a77dc1b commit 948c8ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

examples/EventFilterDemo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from qwt.qt.QtGui import (QApplication, QPen, QBrush, QColor, QWidget,
77
QMainWindow, QPainter, QPixmap, QToolBar, QWhatsThis)
88
from qwt.qt.QtCore import QSize, QEvent, Signal, QRect, QObject, Qt, QPoint
9+
from qwt.qt import PYQT5
910
from qwt import (QwtPlot, QwtScaleDraw, QwtSymbol, QwtPlotGrid, QwtPlotCurve,
1011
QwtPlotCanvas, QwtScaleDiv)
1112

@@ -48,7 +49,10 @@ def dark(self):
4849

4950
def mousePressEvent(self, event):
5051
if event.button() == Qt.LeftButton:
51-
pm = QPixmap.grabWidget(self)
52+
if PYQT5:
53+
pm = self.grab()
54+
else:
55+
pm = QPixmap.grabWidget(self)
5256
color = QColor()
5357
color.setRgb(pm.toImage().pixel(event.x(), event.y()))
5458
self.SIG_COLOR_SELECTED.emit(color)

qwt/plot_canvas.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,11 @@ def setPaintAttribute(self, attribute, on=True):
346346
if QT_VERSION >= 0x050000:
347347
self.__data.backingStore = self.grab(self.rect())
348348
else:
349-
self.__data.backingStore = QPixmap.grabWidget(self,
350-
self.rect())
349+
if PYQT5:
350+
pm = QPixmap.grabWidget(self, self.rect())
351+
else:
352+
pm = self.grab(self.rect())
353+
self.__data.backingStore = pm
351354
else:
352355
self.__data.backingStore = None
353356
elif attribute == self.Opaque:

0 commit comments

Comments
 (0)