Signals and slots

Signals and slots

Signals and slots is a language construct introduced in Qt, which makes it easy to implement the Observer pattern while avoiding boilerplate code. The concept is that controls (also known as widgets) can send signals containing event information (e.g. the text "toto" was selected, the scrollbar has been adjusted to value 37) which can be received by other controls using special functions known as slots. The signal/slot system fits well with the way Graphical User Interfaces are designed. Similarly, the signal/slot system can be used for asynchronous I/O (including sockets, pipes, serial devices, etc.) event notification or to associate timeout events with appropriate object instances and methods or functions. A signal to slot connection is the equivalent of the Design Pattern Observer. No registration/deregistration/invocation code must be written, because Qt's Meta Object Compiler (MOC) automatically generates the needed infrastructure.

There are some implementations of signal/slot systems based on C++ templates, which don't require the extra Meta Object Compiler, as used by Qt, such as libsigc++, [http://sigslot.sourceforge.net/ sigslot] , and [http://www.boost.org/doc/html/signals.html boost.signals] . The C# language also supports a similar construct although with a different terminology and syntax: events play the role of signals, and delegates are the slots. Additionally, a delegate can be a local variable, much like a function pointer, while a slot in Qt must be a class member declared as such.

See also

* Observer pattern
* Signal programming
* Delegate (.NET)

References

* [http://doc.trolltech.com/4.4/signalsandslots.html Signals and slots] , from Qt documentation.


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Signaux et slots — Les signaux et slots sont une implémentation du patron de conception observateur utilisée par les bibliothèques logicielles Qt et Wt. Le concept est que les objets, si leurs classes sont déclarées correctement, peuvent émettre des signaux,… …   Wikipédia en Français

  • Media and Publishing — ▪ 2007 Introduction The Frankfurt Book Fair enjoyed a record number of exhibitors, and the distribution of free newspapers surged. TV broadcasters experimented with ways of engaging their audience via the Internet; mobile TV grew; magazine… …   Universalium

  • Power dividers and directional couplers — A 10 dB 1.7–2.2 GHz directional coupler. From left to right: input, coupled, isolated (terminated with a load), and transmitted port …   Wikipedia

  • Business and Industry Review — ▪ 1999 Introduction Overview        Annual Average Rates of Growth of Manufacturing Output, 1980 97, Table Pattern of Output, 1994 97, Table Index Numbers of Production, Employment, and Productivity in Manufacturing Industries, Table (For Annual… …   Universalium

  • Communications and Networking Riser — CNR slot Communications and Networking Riser (CNR) is a slot found on certain PC motherboards and used for specialized networking, audio, and telephony equipment. A motherboard manufacturer can choose to provide audio, networking, or modem… …   Wikipedia

  • Lead and follow — In partner dancing, the two partners are labelled as the leader and the follower, or lead and follow. Traditionally, the male partner leads and the female partner follows, though this is certainly not always the case. Many social dance forms have …   Wikipedia

  • Signal-Slot-Konzept — Signale und Slots sind ein Konzept aus der Programmierung. Sie realisieren einen ereignisgesteuerten Programmfluss beziehungsweise eine ereignisgesteuerte Kommunikation zwischen Programmobjekten. Ursprünglich geprägt wurde der Begriff durch die… …   Deutsch Wikipedia

  • Signal et slot — Signaux et slots Les signaux et slots sont une implémentation du patron de conception observateur utilisée par la bibliothèque logicielle Qt. Le concept est que les objets, si leurs classes sont déclarées correctement, peuvent émettre des signaux …   Wikipédia en Français

  • Meta-object System — is an extension to C++, part of Qt (toolkit). It is essentially a mechanism that provides two services: Signals and slots and introspection. Elements The Meta object System comprises three elements: The QObject class. This is the base class… …   Wikipedia

  • Сигналы и слоты — Сигналы и слоты  это конструкция языка программирования, используемая в Qt, которая позволяет реализовать шаблон «наблюдатель», минимизируя написание повторяющегося кода. Концепция заключается в том, что компонент (часто виджет) может… …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”