0

我正在使用 Qt 来构建我的应用程序的 GUI,

我了解信号,女巫我正在连接到我的 def (函数),这就是我想要的工作方式。但是除了Signals是Slot,我真的不明白,[signal - function]连接和[signal - slot]连接有什么区别

我以这种方式使用这些东西:

class theOne(QObject):

    started = Signal()

    def __init__(self):
        ...

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

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

有人可以向我解释一下,插槽是做什么用的?关于它们可以带一些参数吗?但正常功能也可以。谢谢你的时间。

4

1 回答 1

0

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 ;)

于 2014-11-18T01:12:43.423 回答