<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Appendix D. Comparison with other signalling systems</title> <link rel="stylesheet" href="style.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Programming with gtkmm"> <link rel="up" href="index.html" title="Programming with gtkmm"> <link rel="prev" href="chapter-custom-signals.html" title="Appendix C. Creating your own signals"> <link rel="next" href="sec-windows-installation.html" title="Appendix E. gtkmm and Win32"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr><th colspan="3" align="center">Appendix D. Comparison with other signalling systems</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="chapter-custom-signals.html"><img src="icons/prev.png" alt="Prev"></a> </td> <th width="60%" align="center"> </th> <td width="20%" align="right"> <a accesskey="n" href="sec-windows-installation.html"><img src="icons/next.png" alt="Next"></a> </td> </tr> </table> <hr> </div> <div class="appendix" title="Appendix D. Comparison with other signalling systems"> <div class="titlepage"><div><div><h2 class="title"> <a name="sec-signals-comparison"></a>Appendix D. Comparison with other signalling systems</h2></div></div></div> <p> TODO: Rewrite this paragraph and talk about QT's moc. (An aside: <span class="application">GTK+</span> calls this scheme "signalling"; the sharp-eyed reader with GUI toolkit experience will note that this same design is often seen under the name of "broadcaster-listener" (e.g., in Metrowerks' PowerPlant framework for the Macintosh). It works in much the same way: one sets up <code class="literal">broadcasters</code>, and then connects <code class="literal">listeners</code> to them; the broadcaster keeps a list of the objects listening to it, and when someone gives the broadcaster a message, it calls all of its objects in its list with the message. In <span class="application">gtkmm</span>, signal objects play the role of broadcasters, and slots play the role of listeners - sort of. More on this later.) </p> <p> <span class="application">gtkmm</span> signal handlers are strongly-typed, whereas <span class="application">GTK+</span> C code allows you to connect a callback with the wrong number and type of arguments, leading to a segfault at runtime. And, unlike <span class="application">QT</span>, <span class="application">gtkmm</span> achieves this without modifying the C++ language.</p> <p> Re. Overriding signal handlers: You can do this in the straight-C world of GTK+ too; that's what GTK's object system is for. But in GTK+, you have to go through some complicated procedures to get object-oriented features like inheritance and overloading. In C++, it's simple, since those features are supported in the language itself; you can let the compiler do the dirty work. </p> <p> This is one of the places where the beauty of C++ really comes out. One wouldn't think of subclassing a GTK+ widget simply to override its action method; it's just too much trouble. In GTK+, you almost always use signals to get things done, unless you're writing a new widget. But because overriding methods is so easy in C++, it's entirely practical - and sensible - to subclass a button for that purpose. </p> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="chapter-custom-signals.html"><img src="icons/prev.png" alt="Prev"></a> </td> <td width="20%" align="center"> </td> <td width="40%" align="right"> <a accesskey="n" href="sec-windows-installation.html"><img src="icons/next.png" alt="Next"></a> </td> </tr> <tr> <td width="40%" align="left" valign="top">Appendix C. Creating your own signals </td> <td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td> <td width="40%" align="right" valign="top"> Appendix E. <span class="application">gtkmm</span> and Win32</td> </tr> </table> </div> </body> </html>