<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font face="Arial, Helvetica, sans-serif">Hi Phil and everybody.</font></p>
<p><font face="Arial, Helvetica, sans-serif">I'm migrating our
largest PyQt4 codebase to PyQt5. The process has been pretty
uneventful until now, when I found this.</font></p>
<p><font face="Arial, Helvetica, sans-serif">I have code with the
following structure. Running it in PyQt4 I got the original,
expected behavior, and clicking the button triggers the
overriden slot. However in PyQt5 the base slot is triggered.</font></p>
<p>--- snip ---<br>
</p>
<font face="Courier New, Courier, monospace">import sys</font><br>
<pre><font face="Courier New, Courier, monospace">#from PyQt4.QtCore import pyqtSlot, QMetaObject
#from PyQt4.QtGui import QApplication, QWidget, QPushButton, QMessageBox
from PyQt5.QtCore import pyqtSlot, QMetaObject
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox
class BaseMixin:
@pyqtSlot()
def on_button_clicked(self):
QMessageBox.information(self, 'Base Widget', 'Base slot')
class OverridenMixin(BaseMixin):
@pyqtSlot()
def on_button_clicked(self):
QMessageBox.information(self, 'Overriden Widget', 'Overriden slot')
class Widget(QWidget, OverridenMixin):
def __init__(self, parent=None):
super().__init__(parent)
self.button = QPushButton("Push me", self)
self.button.setObjectName("button")
self.button.show()
QMetaObject.connectSlotsByName(self)
class App(QApplication):
def __init__(self, argv):
super().__init__(argv)
self._widget = Widget()
self._widget.show()
app = App(sys.argv)
app.exec_()
</font>--- snip ---
</pre>
<font face="Arial, Helvetica, sans-serif">It got weirder as if I
remove the decorators, the overriden slot is triggered, (yet I'd
like to keep using the decorators in order to avoid getting
triggered twice without dealing with the signal's checked
parameter).</font>
<p><font face="Arial, Helvetica, sans-serif">I'm not sure if I'm
doing something subtly wrong, or just using a completely
unsupported way of doing things, and therefore utterly wrong. <br>
</font></p>
<p><font face="Arial, Helvetica, sans-serif">What should I do to get
it working correctly, besides removing the decorators?<br>
</font></p>
<p><font face="Arial, Helvetica, sans-serif">BTW, I'd like to keep
the code working in PyQt4 for a while, but I'm afraid this is
twisted enough to put extra constraints.</font></p>
<p><font face="Arial, Helvetica, sans-serif">Thanks in advance.<br>
</font></p>
<p><font face="Arial, Helvetica, sans-serif">Julio.<br>
</font></p>
</body>
</html>