How does the Qt Slots works. PySide

160 views Asked by At

I am working with Qt I used to build GUI of my application,

I understand the Signals, witch I am connecting to my def (functions) and that is working how I want to. But beside Signals are Slot, and I don't really get, what is the difference between [signal - function] connection and the [signal - slot] connection

I'm using this stuff this way:

class theOne(QObject):

    started = Signal()

    def __init__(self):
        ...

    def function(self):
        self.started.connect(self.goStart)
        self.started.emit()

    def goStart(self):
        """some actions"""

Could somebody try to explain me, what are the Slots for? Its about they can take some parameters? But normal functions also does. Thanks for Your time.

1

There are 1 answers

1
Nox On BEST ANSWER

Slots are functions. The only difference between slots and functions is that with the slot keyword, the Qt metaobject compiler (MOC) will grab a function pointer of that function and use it for it's own purpose (like responding to a signal). You can totally reproduce that kind of process by grabbing a pointer of one of your function and call it when a boolean is on true.

Hope that helps.

PS: My background and skills are more C++ related but you should get my point ;)