Skip to content Skip to sidebar Skip to footer

Issue Trying To Use A Class's Name In It's Own Class Variable Section

I'm writing an app in Python and PyQt right now, and I've having a bit of an issue. This problem doesn't require an knowledge of PyQt itself, just that of static variables in pyth

Solution 1:

Sound like this signal pass own class variable. From reference this pyqt signal. It possibly to use QObject. (not Foo but subclass is same)

Or, if your want to pass anything object, I think your can use object;

classFoo(QObject):
    updated =pyqtSignal(object)
    moved = pyqtSignal(object)

And your can specified what class should be emit it in pyqt connect signal.

Solution 2:

The problem is that the statement updated = pyqtSignal(Foo) is evaluated while Foo is being constructed, so Foo doesn't exist when that statement is evaluated.. In the general case, you'd have to move it outside the class definition, although there may be some pyqt magic (e.g. using QObject rather than Foo as described in the other answer):

classFoo(...):
   ...

Foo.updated =pyqtSignal(Foo)

Post a Comment for "Issue Trying To Use A Class's Name In It's Own Class Variable Section"