I don't suppose there's any sample code out there that implements this is there?
I don't suppose there's any sample code out there that implements this is there?
Bueller....
Receiver:
Qt Code:
connect(channel, SIGNAL(received(QString, QByteArray)), this, SLOT(receiveMessage(QString, QByteArray)));To copy to clipboard, switch view to plain text mode
Sender:
Qt Code:
To copy to clipboard, switch view to plain text mode
J-P Nurmi
So in your code example, "data" is supposed to be a custom event? It looks like it's supposed to be a QByteArray.
QCopChannel is not a way to send specifically "events", but any data. You can serialize an event on one end and deserialize it on the other end and dispatch it to the desired object. Of course both sides of communication have to be aware and ready for such mechanism - you can't communicate with any arbitrary application like that.
TTGator (14th January 2009)
Yes, I want to create a QServer process and have it start another QProcess and communicate with events. So I am trying to figure out how to first, create a custom event, and second, how to send that event from one process to the other.
Thank you for the order flow I need, so I guess I need to know how to:
1) Create a custom event (doc mentions extending QEvent, and somehow giving it an id above 1000 to designate it as a custom event)
2) serialize the event
3) send it on QCopChannel
4) deserialize the event
5) dispatch it
Is this not a common task that would have some sample code around for me to investigate? Or is there a better way to communicate between processes in an event driven manner?
I would skip step 1 and change step 4 to "create an event based on data received through QCop".
You mean just pass something like the Event ID through QCop and convert it into an event on the receiving side? I want the events to be able to be sent to and from the client process. Seems like it would make more sense to have well defined events and send them. No? Otherwise you have to have values associated with events on both sides and keep track of them separately and make sure they are in sync.
Bookmarks