Home > Mobile >  Qt is encapsulated SendMessage mechanism? Especially under the MAC like Windows
Qt is encapsulated SendMessage mechanism? Especially under the MAC like Windows

Time:09-27

Signal still has its limitations,
Is binding, need to know the sender and the receiver, but similar to callback functions,

I want to sender and receiver decoupling,
I.e., the sender and recipient who is don't know each other,
The sender does not know who a message is received; The receiver also don't know who send a message,

By the way, they want to allow binding some data,

CodePudding user response:

Yes, use postEvent or adds and then the receiver in the eventloop handle these event.
As long as the attention, the use of difference between these two functions, mainly is the ownership of the event

CodePudding user response:

PostEvent and adds also need to specify the receiver, Qt does not provide the function of the global send events,
In addition there is some difference between the signal/slot and callback:
1: if you give an object A set A callback, the callback is A member of the object B function, if the object is destroyed, B A, don't know if the callback is effective, but in fact the callback can no longer be invoked, if the signal/slot, sender trigger signal does not need to worry about the receiver has been destroyed, because at the time of destruction of all connections have been disconnected,
2: if multiple objects need to monitor an object, you can pass on the monitored object set up multiple callback to monitor the object, so be monitored object would need to maintain a list to store multiple callback, and signal/slot only need inside the loop connection is monitoring objects and monitoring objects,

CodePudding user response:

It had to use message queue to decoupling, the rabbitMQ, kafka,
  •  Tags:  
  • Qt
  • Related