[PyQt] the mechanism behind qt signal and slot

Algis Kabaila akabaila at pcug.org.au
Sun Sep 19 09:18:15 BST 2010


On Sunday 19 September 2010 17:41:59 Von wrote:
> Hi,Algis,
> I have looked through this chapter "Events, the Clipboard, and Drag and
> Drop", and I couldn't find anything about signal/slot mechanism.
> 
> Best Regards

Ch 10 does not talk about Signals-Slots directly, but it tells the details 
about the lower level events.  It is the same and one mechanism as Signals-
Slots, it is just that it is looked  at from a different perspective. I think 
that usually the "signal" is caught by the "slot" and acted on it as required. 
OTH, if the signal is not caught by a "slot" it travels up the widget tree to 
the very top level widget and if it is not caught there, it is simply dropped 
(ignored).

BTW, the syntax of signal/slot is undergoing a change.  So when signal-slot is 
created by the Qt Designer, its format is, for example, as follows

self.connect(self.action_New, SIGNAL("triggered()"), self.fileNew)

The new style syntax would lead to a different looking expression, namely:

self.action_New.triggered.connect(self.fileNew)

Both forms have exactly the same effect. action_New (perhaps connected to a 
button) is "triggered" when the button is clicked. "Slot" in both formats can 
be a Python executable, viz. function fileNew.  Does this help at all? (It 
exhausts my limited knowledge of the subject).

Al.

-- 
OldAl
akabaila at pcug.org.au


More information about the PyQt mailing list