Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signals and slots,design pattern in Qt?

I was wondering about the design pattern behind the signals and slots mechanism in Qt?

I am hesitating between the mediator and observer one?

Thank you...

like image 330
Maxence SCHMITT Avatar asked Jan 07 '11 12:01

Maxence SCHMITT


1 Answers

QT's signals and slots is an implementation of the Observer pattern. If you want to know more about it, I recommend reading A Deeper Look at Signals and Slots which motivates it and compares it to Boost signals. Otherwise, there's always the QT docs.

If you want to use the Mediator pattern instead of the Observer pattern, it would be fairly trivial to do this using QT. You'd have to add a mediator class into the mix, and make it your observer of the events of interest; i.e. move the slots and most of your update logic from your regular observers to your mediator.

like image 115
asdfjklqwer Avatar answered Sep 24 '22 06:09

asdfjklqwer