[PyQt] signals/slots don't work for QQuickItem derived class

Phil Thompson phil at riverbankcomputing.com
Tue Apr 10 18:58:09 BST 2018


I think this is fixed in tonight's snapshot. However, as always with QtQuick/QML changes, regressions can be difficult to avoid so testing is recommended.

Phil

> On 30 Mar 2018, at 7:55 am, Alexander Rössler <alexander at roessler.systems> wrote:
> 
> Yes, here we go:
> https://github.com/machinekoder/demonstrate-pyqt-bug
> 
> Alex
> 
> Phil Thompson writes:
> 
>> On 29 Mar 2018, at 4:28 pm, Alexander Rössler <alexander at roessler.systems> wrote:
>>> 
>>> 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?
>> 
>> Can you send me a *complete* example that demonstrates the problem.
>> 
>> Phil
> 
> 
> -- 
> 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