Qt Eventing without know receiver (decoupling of objects) possible?



  • Hi,

    I want to be able to send events to objects, so for so good because I can use Qt eventing (postEvent) :-) !

    But I also want that the sending and receiving objects are decoupled! I don't want the sender object to have any knowledge of the receiving object. And as far as I can see you need to enter a receiver QObject * to postEvent method :-(

    Is it possible with Qt eventing to send events and whoever listens receives this event and can handle/ignore it?

    Thanks a lot!



  • Why not just use a signal?



  • Because signal/slots are synchronous, right? And I still need to have both objects to "connect" each other.

    I would like a mechanism where you can thrown something in the event queue and all objects listening to that queue can use or ignore the event. Is this possible with Qt Eventing?



  • If you specify Qt::QueuedConnection in your connect statement then the signals make use of the receiver object's event queue (must have event loop running though) rather than being synchronous direct function calls.



  • no, it is not.

    Events are always send to a receiver. You always send to a target. send to unknown objects is signal/slot, but then you need the connect statement, that's correct.

    What you could theoretically do is send the event to the QApplication and everybody can install an event filter there and handle them. But that's not a nice design.



  • Ok, too bad. I guess I'll have to find another way to do this.

    Thnx!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.