qt:signals_and_slots
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
qt:signals_and_slots [2010/12/09 14:28] – [Multiple connections] mithat | qt:signals_and_slots [2011/04/01 11:10] (current) – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Signals and slots ====== | ====== Signals and slots ====== | ||
- | Events are handled | + | Communication between objects |
===== Making connections ===== | ===== Making connections ===== | ||
A connection between a signal and a slot is made as follows: | A connection between a signal and a slot is made as follows: | ||
<code cpp-qt> | <code cpp-qt> | ||
- | QObject:: | + | QObject:: |
- | {pointer to receiver}, SLOT({slot-name}({parameter-type(s)}))); | + | <pointer-to-receiver>, SLOT(<slot-name>(<parameter-type(s)>))); |
</ | </ | ||
- | The emiter emits the signal '' | + | The emiter emits the signal '' |
- | For example:((From Molkentin, p. 37)) | + | Example:((From Molkentin, p. 37)) |
<code cpp-qt> | <code cpp-qt> | ||
QSpinBox* spinBox = new QSpinBox; | QSpinBox* spinBox = new QSpinBox; | ||
Line 23: | Line 23: | ||
</ | </ | ||
- | The '' | + | The '' |
+ | |||
+ | The number of parameters emited by a signal is allowed to be greater than the number of parameters received by a slot; extra parameters are ignored. | ||
+ | |||
+ | Errors in connecting signals and slots are not reported in compiling or linking. However, they will produce a runtime warning: \\ | ||
+ | \\ | ||
+ | '' | ||
===== Multiple connections ===== | ===== Multiple connections ===== | ||
- | Signals may connect to multiple slots. | + | Signals may connect to multiple slots. |
- | If a signal connects to multiple | + | In the case of multiple |
===== Writing your own slots ===== | ===== Writing your own slots ===== | ||
Line 35: | Line 41: | ||
===== Writing your own signals ===== | ===== Writing your own signals ===== | ||
A number of signals are defined for many of the classes that make up Qt. It is also possible to implement new (or override existing :?:) signals. | A number of signals are defined for many of the classes that make up Qt. It is also possible to implement new (or override existing :?:) signals. | ||
+ | |||
+ | ===== Examples ===== | ||
+ | Some examples are [[signal slot examples|here]]. | ||
+ |
qt/signals_and_slots.1291904886.txt.gz · Last modified: 2010/12/09 14:28 by mithat