One signal can be connected to many slots: connect(slider, SIGNAL(valueChanged(int)),Ĭonnect(slider, SIGNAL(valueChanged(int)), There are other possibilities to consider. In the examples we have seen so far, we have always connected different signals to different slots. The SIGNAL() and SLOT() macros essentially convert their argument to a string. Where sender and receiver are pointers to QObjects and where signal and slot are function signatures without parameter names. The connect() statement looks like this: connect( sender, SIGNAL( signal), receiver, SLOT( slot)) The difference is that a slot can also be connected to a signal, in which case it is automatically called each time the signal is emitted. They can be virtual they can be overloaded they can be public, protected, or private they can be directly invoked like any other C++ member functions and their parameters can be of any types. Slots are almost identical to ordinary C++ member functions. Let's take a moment to look at the mechanism more closely. We have already connected some signals and slots together, declared our own signals and slots, implemented our own slots, and emitted our own signals. It enables the application programmer to bind objects together without the objects knowing anything about each other. The signals and slots mechanism is fundamental to Qt programming. Learn More Buy Signals and Slots in Depth C++ GUI Programming with Qt4, 2nd Edition