Signals and slots can take any number of arguments of any type. Qt’s signals and slots mechanism ensures that if you connect a signal to a slot, the slot will be called with the signal’s parameters at the right time. Signals and slots are loosely coupled: A class which emits a signal neither knows nor cares which slots receive the signal. The string-based SIGNAL and SLOT syntax will detect type mismatches at runtime. (In fact a slot may have a shorter signature than the signal it receives because it can ignore extra arguments.) Since the signatures are compatible, the compiler can help us detect type mismatches when using the function pointer-based syntax. The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot. Qt’s widgets have many pre-defined slots, but it is common practice to subclass widgets and add your own slots so that you can handle the signals that you are interested in. A slot is a function that is called in response to a particular signal. Qt’s widgets have many predefined signals, but we can always subclass widgets to add our own signals to them. A signal is emitted when a particular event occurs. In Qt, we have an alternative to the callback technique: We use signals and slots.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |