Hi All,
The PyQt Reference Guide says:
"It is not possible to define a new Python class that sub-classes from
more than one Qt class."
[
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#multiple-inheritance
]
The code attached works here until you remove the comment before the
last line. Then it raises a TypeError.
I should really use something like this in a PyQt app (if it's not a
very bad idea anyway) and I wonder what are the limitations here or what
are the best practices to solve this kind of problem (if there are any).
versions:
PyQt: 4.8.3
Qt: 4.7.1
sip: 4.12.1
python: 2.6.5
bests
Zoli
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class ModelBase(QObject):
baseSignal = pyqtSignal()
def __init__(self, parent):
QObject.__init__(self, parent)
@pyqtSlot()
def baseSlot(self):
print 'baseSlot called'
@pyqtSlot()
def onModelReset(self):
print 'onModelReset called'
class AModel(ModelBase, QAbstractItemModel):
aSignal = pyqtSignal()
def __init__(self, parent=None):
QAbstractItemModel.__init__(self, parent)
ModelBase.__init__(self, parent)
@pyqtSlot()
def aSlot(self):
print 'aSlot called'
class BModel(ModelBase, QAbstractTableModel):
bSignal = pyqtSignal()
def __init__(self, parent=None):
QAbstractTableModel.__init__(self, parent)
ModelBase.__init__(self, parent)
@pyqtSlot()
def bSlot(self):
print 'bSlot called'
app = QApplication([])
a = AModel()
b = BModel()
a.baseSignal.connect(a.baseSlot)
a.baseSignal.emit()
b.bSignal.connect(b.bSlot)
b.bSignal.connect(b.baseSlot)
b.bSignal.emit()
print a.modelReset
#a.modelReset.connect(a.onModelReset)
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt