I'm trying to understand signals and slots....
read a couple of things
http://www.harshj.com/2010/05/06/pyqt-faq-custom-signals-jpeg-mouse-hovers-and-more/#custom
http://zetcode.com/tutorials/pyqt4/eventsandsignals/
and here is the question:
class bla(object):
blaSignal = QtCore.pyqtSignal()
works but
class bla(object):
def __init__(self):
self.blaSignal = QtCore.pyqtSignal()
doesn't work and it states something about the signal not being bound... What do I not understand here? Why does one work?
Thanks
The problem here is that you want there to be a single signal that's shared by all bla
objects.
If you had a different signal for each bla
, nobody would be able to connect up any signal without knowing about the particular bla
instance that owned the particular signal. That would be bad enough within the program, but imagine how something like QtDesigner
or the QMetaObject
-based introspection would handle it. Even if it created a bla
instance, that wouldn't be the same bla
instance your code created at runtime.
This is somewhat explained in Defining New Signals with pyqtSignal()
in the docs.