hi<br><br>The following is an extract from  the book "Foundations of Qt Development" by Johan Thelin. This explains how signal is implemented in Qt. Thanks Mr.Johan Thelin.<br><br><br><br><br>"Signals and slots are implemented by Qt using function pointers. When calling emit with the signal as argument, you actually call the signal. The signal is a function implemented in the source file generated by the moc. This function calls any slots connected to the signal using the meta-objects of the objects holding the connected slots.<br>
<br>The meta-objects contain function pointers to the slots, along with their names and argument types.They also contain a list of the available Signals and their names and argument types. When calling connect,<br>you ask the meta-object to add the slot to the signal’s calling list. If the arguments match, the connection is made.When matching arguments, the match is checked only for the arguments accepted by the slot. This<br>
means that a slot that does not take any arguments matches all signals. The arguments not accepted by the slot are simply dropped by the signal-emitting code."<br><br><br><div class="gmail_quote">On Mon, Sep 20, 2010 at 8:57 AM, Von <span dir="ltr"><<a href="mailto:vontio@gmail.com">vontio@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Many thanks,Andreas.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Mon, Sep 20, 2010 at 2:09 AM, Andreas Pakulat <span dir="ltr"><<a href="mailto:apaku@gmx.de" target="_blank">apaku@gmx.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>On 19.09.10 18:15:15, Von wrote:<br>
> Hi,Algis,many thanks for all these informations.<br>
> At first I thought QtCore.QtObject.connect as static method of<br>
> QtObject,later I realized that,this is py style of calling super method.<br>
> That's why I asked question (3).<br>
> The document of pyqt says "The code (or component) that emits the signal<br>
> does not know or care if the signal is being used."<br>
> In my head,the implementation of signal and slot is an observer pattern.<br>
> Pseudo-code:<br>
> def connect(source,signal,slot):<br>
>     if(not source.slots[signal]):<br>
>         source.slots[signal] = []<br>
>     source.slots[signal].append(slot)<br>
><br>
> def emit(signal,param):<br>
>     for slot in self.slots[signal]:<br>
>         slot(param)<br>
> I am wondering why signal does not know what slots bind with it?<br>
<br>
</div>That pseudo code is pretty close to reality, except that (in C++ Qt)<br>
emit is just a macro and the for slot in slots-stuff is in the<br>
moc-generated code. So the signal does know which slots are connected,<br>
but whoever call emit mysignal doesn't know and doesn't care. Thats the<br>
point of loosely coupled objects and encapsulation. The code that emits<br>
the signal always does so, no matter wether there are any connected<br>
slots or not. So the for-loop might not run its body even once, but the<br>
'emission' is always done. Thats what is meant with 'the code that emits<br>
the signal doesn't know or care if the signal is being used'<br>
<br>
Andreas<br>
<font color="#888888"><br>
--<br>
Your step will soil many countries.<br>
</font><div><div></div><div>_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br>