Results 1 to 10 of 10

Thread: How to communicate Qt Process with non-qt process

  1. #1
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Wink Dbus with different process

    Hi,

    How to Communicate 2 different process running on the same host using Dbus?(ARM in my case).


    I have few confusion regarding use and implementation of qt Dbus. I am using Qt for Embedded Linux 4.4.

    My scenario,
    I am developing one device having GUI interface which works as SLAVE and connected to MASTER. SLAVE's main process will communicate with MASTER for sending and receiving messages.

    I want to display this messages coming for MASTER.

    Process 1:- Main Process take cares of hardware drivers and send and receive messages from MASTER (distributed architecture). e.g.:- ./MainProcess
    Process 2:- Separate Qt process for GUI Display. e.g.:- ./QtProcess

    Can anybody guide me how to solve this problem?
    Immediate response would be highly appreciable.

    Thanks in Advance,
    Nirav


  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Dbus with different process

    What is the exact problem? Have you managed to connect to the session bus with both applications?

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

    nrabara (23rd January 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Dbus with different process

    I don't know how to create session between two different process. Would you please explain me?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Dbus with different process

    Have you seen the dbus examples that come with Qt?

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

    nrabara (23rd January 2009)

  7. #5
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Dbus with different process

    Yes, I have seen that Dbus examples. but these examples are only for Qt applications(I mean to communicate to different Qt application).

    As per my knowledge(might be wrong also)I need to use QCopChannel to Communicate Qt and non-Qt Application.

    there is no examples for QCopChannel.

    waiting for feedback, your suggestion would be helpful for me.

  8. #6
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Exclamation How to communicate Qt Process with non-qt process

    Hi,

    I would be really thankful if anybody tell me how to communicate qt Process with not non-Qt process.

    I have read DBus and QCopChannel but still not clear about it.

    Your immediate response would be highly appreciable.

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Dbus with different process

    So you want to use D-Bus or QCopChannel? D-BUS can be used to communicate between Qt and non-Qt application. With QCopChannel I think this is not possible.

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to communicate Qt Process with non-qt process

    Please don't start multiple threads on the same subject - threads merged.

  11. #9
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to communicate Qt Process with non-qt process

    Hi,
    You can use QCopChannel. You need a Qt App object though in your non-gui process.
    1) In your gui application, start it as such QApplication app(argc,argv, QApplication::GuiServer);
    2) then in your non-gui app you need this QApplication app(argc,argv, QApplication::GuiClient);
    3) Get your server app (gui application) to start the client app. Using QProcess::start("clientapp"). Start it once the the server app has already entered the event loop. i.e for example when the window is shown.
    4)You need to declare a QCopChannel object in your gui app, and receive the events from your client process. In my case I have a channel called "gpio", I declare the QCopchannel("gpio"). This registers the channel. Then whenever your non-gui app sends events to ("gpio") channel your gui app will receive them. You have to implement the receive event in your gui-app.
    This is a brief explaination but it should set you in the right direction.

    Then you need to send the Server app (your Qt app) a message. This is a helper function you don't need it.
    Qt Code:
    1. int sendEventWData(char *string, unsigned char *buf, int size)
    2. {
    3. // QByteArray::fromRawData((const char *)buf,size);
    4. sendQCopEvent(GPIO,string,QByteArray::fromRawData((const char *)buf,size));
    5. return 0;
    6. }
    7.  
    8. int sendQCopEvent( char *channel, char *string, const QByteArray &data)
    9. {
    10. if(QCopChannel::isRegistered(channel))
    11. {
    12. QCopChannel::send(channel, string, data);
    13. QCopChannel::flush();
    14. return 0;
    15. }
    16. return -1;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 25th January 2009 at 09:53. Reason: missing [code] tags

  12. The following user says thank you to QbelcorT for this useful post:

    nrabara (30th January 2009)

  13. #10
    Join Date
    May 2008
    Location
    Spain
    Posts
    92
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to communicate Qt Process with non-qt process

    Hello,

    I use Share Memory to comunicate varibales between nonQT and QT process

  14. The following user says thank you to webquinty for this useful post:

    nrabara (16th February 2009)

Similar Threads

  1. Process Read/Write
    By QbelcorT in forum Newbie
    Replies: 0
    Last Post: 20th November 2008, 03:08

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.