Signals and slots,design pattern in Qt?
I was wondering about the design pattern behind t开发者_JAVA百科he signals and slots mechanism in Qt?
I am hesitating between the mediator and observer one?
Thank you...
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.
精彩评论