Results 1 to 10 of 10

Thread: Pass custom events to another process

  1. #1
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Pass custom events to another process

    I see some documentation about passing events from object to object, but is there a way to pass custom events to another process that was created by the qws server? (Embedded)

    I'm assuming that QCOP is somehow involved... but I'm REALLY new to Qt, so any direction would be much appreciated!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Pass custom events to another process

    Both processes can create an instance of QCopChannel with same channel name.
    J-P Nurmi

  3. #3
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Pass custom events to another process

    I don't suppose there's any sample code out there that implements this is there?

  4. #4
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Pass custom events to another process

    Bueller....

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Pass custom events to another process

    Receiver:
    Qt Code:
    1. QCopChannel* channel = new QCopChannel("mychannel", this);
    2. connect(channel, SIGNAL(received(QString, QByteArray)), this, SLOT(receiveMessage(QString, QByteArray)));
    To copy to clipboard, switch view to plain text mode 

    Sender:
    Qt Code:
    1. QCopChannel::send("mychannel", message, data);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. #6
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Pass custom events to another process

    So in your code example, "data" is supposed to be a custom event? It looks like it's supposed to be a QByteArray.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Pass custom events to another process

    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.

  8. The following user says thank you to wysota for this useful post:

    TTGator (14th January 2009)

  9. #8
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Pass custom events to another process

    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?

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Pass custom events to another process

    I would skip step 1 and change step 4 to "create an event based on data received through QCop".

  11. #10
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Pass custom events to another process

    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.

Similar Threads

  1. Replies: 1
    Last Post: 13th September 2008, 14:45
  2. Capture events in a custom delegate
    By vfernandez in forum Qt Programming
    Replies: 9
    Last Post: 19th March 2008, 05:33
  3. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 10:52
  4. Posting custom events to a subclass of QThread
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2006, 15:49
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.