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

Alexander Rössler alexander at roessler.systems
Fri Mar 30 07:55:25 BST 2018


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