[PyQt] signals/slots don't work for QQuickItem derived class
Alexander Rössler
alexander at roessler.systems
Thu Mar 29 16:28:30 BST 2018
Hello everyone,
I have something weird happening.
Take a look at this code:
class WidgetController(QQuickItem):
nameChanged = pyqtSignal(str)
proxyChanged = pyqtSignal(WidgetProxy)
def __init__(self, parent=None):
super(WidgetController, self).__init__(parent)
self._name = ''
self._proxy = None
self._widget = None
self.nameChanged.connect(self._update_widget)
self.proxyChanged.connect(self._update_widget)
...
def _update_widget(self):
if not self._proxy:
return
self._widget = self._proxy.widgets.get(self._name, None)
During instantiation from QtQuick I get following error:
QObject::connect: No such signal QQuickItem::nameChanged(QString)
Traceback (most recent call last):
File ".../base/widgetcontroller.py", line 19, in __init__
self.nameChanged.connect(self._update_widget)
TypeError: connect() failed between WidgetController.nameChanged[str]
and unislot()
Exactly the same code works as intended when I subclass QObject instead
of QQuickItem. What am I doing wrong here?
Best regards
Alexander
--
Alexander Rössler
HMI Expert at Rössler Systems
Tel: +43 680 1348338
Web: https://roessler.systems
Blog: https://machinekoder.com
alexander at roessler.systems
Lebnergasse 1/7/7
1210 Wien - Austria
ATU72251528
More information about the PyQt
mailing list