Reputation: 141
I was working on getting up to speed with QT, QML and Pyside2 (Qt for Python) and found I had some issues partly because I was creating the Properties object as an instance inside __init__()
and it was not working. Once I put it as a Class object, how the examples show me, it worked. But I am having trouble understanding exactly why.
active_site_prop = Property(int, get_site_num, set_site_num, notify=site_num_changed)
vs
def __init__(self):
QObject.__init__(self)
self.active_site_prop = Property(int, self.get_site_num, self.set_site_num, notify=self.site_num_changed)
My references
Upvotes: 1
Views: 143
Reputation: 243887
You cannot implement q-properties in runtime as well as the q-signals and q-slots since in C++ you cannot do an introspection in run-time so the MOC (MetaObject Compiler) implements that introspection in compile-time. This same concept is exported by bindings, and in the case of q-properties they have a similar behavior to native properties.
Upvotes: 2