Fixed a Qt5 incompatability issue (replaced QPixmap.grabWidget() by QWidget.grab()).

Sat, 09 Mar 2013 13:42:57 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 09 Mar 2013 13:42:57 +0100
changeset 2467
33f1bcfdd65e
parent 2464
d6bba153dd43
child 2470
206ff86e34c8

Fixed a Qt5 incompatability issue (replaced QPixmap.grabWidget() by QWidget.grab()).

E5Gui/E5ModelMenu.py file | annotate | diff | comparison | revisions
E5Gui/E5ModelToolBar.py file | annotate | diff | comparison | revisions
Tools/UIPreviewer.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5ModelMenu.py	Mon Mar 04 19:12:44 2013 +0100
+++ b/E5Gui/E5ModelMenu.py	Sat Mar 09 13:42:57 2013 +0100
@@ -7,7 +7,7 @@
 Module implementing a menu populated from a QAbstractItemModel.
 """
 
-from PyQt4.QtCore import pyqtSignal, Qt, QModelIndex, QPoint
+from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint
 from PyQt4.QtGui import QMenu, QFontMetrics, QAction, QApplication, QDrag, QPixmap
 
 import UI.PixmapCache
@@ -378,7 +378,10 @@
         drag = QDrag(self)
         drag.setMimeData(self.__model.mimeData([idx]))
         actionRect = self.actionGeometry(act)
-        drag.setPixmap(QPixmap.grabWidget(self, actionRect))
+        if qVersion() >= "5.0.0":
+            drag.setPixmap(self.grab(actionRect))
+        else:
+            drag.setPixmap(QPixmap.grabWidget(self, actionRect))
         
         if drag.exec_() == Qt.MoveAction:
             row = idx.row()
--- a/E5Gui/E5ModelToolBar.py	Mon Mar 04 19:12:44 2013 +0100
+++ b/E5Gui/E5ModelToolBar.py	Sat Mar 09 13:42:57 2013 +0100
@@ -7,7 +7,7 @@
 Module implementing a tool bar populated from a QAbstractItemModel.
 """
 
-from PyQt4.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent
+from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint, QEvent
 from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, QToolButton
 
 
@@ -241,7 +241,10 @@
         drag = QDrag(self)
         drag.setMimeData(self.__model.mimeData([idx]))
         actionRect = self.actionGeometry(act)
-        drag.setPixmap(QPixmap.grabWidget(self, actionRect))
+        if qVersion() >= "5.0.0":
+            drag.setPixmap(self.grab(actionRect))
+        else:
+            drag.setPixmap(QPixmap.grabWidget(self, actionRect))
         
         if drag.exec_() == Qt.MoveAction:
             row = idx.row()
--- a/Tools/UIPreviewer.py	Mon Mar 04 19:12:44 2013 +0100
+++ b/Tools/UIPreviewer.py	Sat Mar 09 13:42:57 2013 +0100
@@ -7,7 +7,7 @@
 Module implementing the UI Previewer main window.
 """
 
-from PyQt4.QtCore import QDir, QFileInfo, QEvent, QSize, Qt
+from PyQt4.QtCore import qVersion, QDir, QFileInfo, QEvent, QSize, Qt
 from PyQt4.QtGui import QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QCursor, \
     QPrinter, QKeySequence, QPrintDialog, QWhatsThis, QPixmap, QImageWriter, QPainter, \
     QDialog, QScrollArea, qApp, QApplication, QStyleFactory, QFrame, QMainWindow, \
@@ -447,7 +447,10 @@
             ext = defaultExt
             fname.append(".{0}".format(defaultExt.lower()))
         
-        pix = QPixmap.grabWidget(self.mainWidget)
+        if qVersion() >= "5.0.0":
+            pix = self.mainWidget.grab()
+        else:
+            pix = QPixmap.grabWidget(self.mainWidget)
         self.__updateChildren(self.lastStyle)
         if not pix.save(fname, str(ext)):
             E5MessageBox.critical(self,
@@ -466,7 +469,10 @@
             return
         
         cb = QApplication.clipboard()
-        cb.setPixmap(QPixmap.grabWidget(self.mainWidget))
+        if qVersion() >= "5.0.0":
+            cb.setPixmap(self.mainWidget.grab())
+        else:
+            cb.setPixmap(QPixmap.grabWidget(self.mainWidget))
         self.__updateChildren(self.lastStyle)
     
     def __printImage(self):
@@ -554,7 +560,10 @@
             marginX *= 2
             width = printer.width() - marginX * 2
             height = printer.height() - marginY * 2
-        img = QPixmap.grabWidget(self.mainWidget).toImage()
+        if qVersion() >= "5.0.0":
+            img = self.mainWidget.grab().toImage()
+        else:
+            img = QPixmap.grabWidget(self.mainWidget).toImage()
         self.__updateChildren(self.lastStyle)
         p.drawImage(marginX, marginY,
                     img.scaled(width, height,

eric ide

mercurial