Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt signals and slots - are they intended for GUI only or for entire app architecture?

I'm very curious - are Qt's signals and slots (delegate pattern?) intended only for GUI callbacks, or they are perfectly fine and intended for entire apps? I mean, is it better to split apps into small, self-contained objects (classes) and interconnect them via signals and slots? And if so, what is the recommended way to return a value from a signal (request-like signal that is used to return something), since Qt's signals' return values are ignored?

like image 427
grigoryvp Avatar asked Dec 02 '22 06:12

grigoryvp


1 Answers

QT's signals and slots are not intended for returning values from the reciver. They are a strictly one way communication mechanism.

The receiver may actually be in a completely different thread, receiving the signal from a queue, way after the sender emit call returned.

As for using it for anything other than GUI.. you can use them for wherever it fit, if it fits there. why single out GUI as something special?

like image 126
shoosh Avatar answered Dec 23 '22 06:12

shoosh