Toolbox/PyQt4ImportHook.py

changeset 5802
abfb67a6f376
parent 5389
9b1c800daff3
child 5814
50b299f6eb98
--- a/Toolbox/PyQt4ImportHook.py	Mon Jul 10 19:12:12 2017 +0200
+++ b/Toolbox/PyQt4ImportHook.py	Tue Jul 11 21:25:35 2017 +0200
@@ -44,6 +44,21 @@
             
             return None
         
+        @staticmethod
+        def QComboBox_currentData(other, role=None):
+            """
+            Public method to emulate the currentData method of Qt5.
+            
+            @param role role of which data should be retrived
+            @return stored data at current selection
+            """
+            import PyQt4.Qt
+            if role is None:
+                role = PyQt4.Qt.Qt.UserRole
+            
+            idx = other.currentIndex()
+            return other.itemData(idx, role)
+        
         def load_module(self, fullname):
             """
             Public method to load a module.
@@ -69,6 +84,8 @@
                     PyQt4.QtGui.QSortFilterProxyModel
                 module.QAbstractProxyModel = PyQt4.QtGui.QAbstractProxyModel
                 module.QStringListModel = PyQt4.QtGui.QStringListModel
+                
+                PyQt4.QtGui.QComboBox.currentData = self.QComboBox_currentData
             return module
 
     sys.meta_path.insert(0, PyQt4Importer())

eric ide

mercurial