[PySide] @Property syntax broken?

Cristián Maureira-Fredes Cristian.Maureira-Fredes at qt.io
Wed Feb 27 09:51:17 CET 2019


Hello Maxime,

you are right, that's a real bug.
Luckily we managed to solve that issue and it will be included in the next release.
https://codereview.qt-project.org/#/c/252324/

Cheers

________________________________________
From: PySide <pyside-bounces at qt-project.org> on behalf of Maxime Lemonnier <maxime.lemonnier at gmail.com>
Sent: 25 February 2019 22:47
To: pyside at qt-project.org
Subject: [PySide] @Property syntax broken?

Hi, using the latest pyside2 from PyPi (version 5.12). I fail to use the decorator syntax with PySide2:

The following works:

-----------------------------------------------------------
from PySide2.QtCore import Signal, Property, Slot, QObject, QTimer
class Foo(QObject):
    def __init__(self, parent=None):
        super(Foo, self).__init__(parent)

    autoUpdateChanged = Signal()
    def autoUpdate_(self):
        return self._autoUpdate

    def autoUpdate__(self, d):
        if self._autoUpdate != d:
            self._autoUpdate = d
            self.autoUpdateChanged.emit()

    autoUpdate = Property(bool, autoUpdate_, autoUpdate__, notify = autoUpdateChanged)


The following fails with Cannot assign to non-existent property "autoUpdate" :

------------------------------------------------------------------------------------
from PySide2.QtCore import Signal, Property, Slot, QObject, QTimer
class Foo(QObject):
    def __init__(self, parent=None):
        super(Foo, self).__init__(parent)

    autoUpdateChanged = Signal()
    @Property(bool, notify = autoUpdateChanged)
    def autoUpdate(self):
        return self._autoUpdate

    @autoUpdate.setter
    def autoUpdate(self, d):
        if self._autoUpdate != d:
            self._autoUpdate = d
            self.autoUpdateChanged.emit()



--------------------------

Am-I missusing the syntax? I googled for more than one hour in search for a similar issue before posting here.

Thank you


More information about the PySide mailing list