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

Phil Thompson phil at riverbankcomputing.com
Thu Mar 29 16:38:11 BST 2018


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


More information about the PyQt mailing list