Results 1 to 4 of 4

Thread: Sending signal to other process?

  1. #1
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Sending signal to other process?

    Hello,
    when a special button is clicked my application starts a new process with a different application QProcess::startDetached( "OtherApp.exe" );
    Now I want the new application to signal the first application to quit.

    First I thought about using D-Bus for Inter-Process Communication (IPC), but as I am developing for Windows D-Bus cannot be used (Unix only).
    QCOP is for Qt Embedded Linux only.
    This leaves TCP/IP and Shared Memory as remainders of the proposed ways to implement IPC.

    But how can I use them (or only one of them) to signal from one application to another?
    Are there other ways to achieve this?

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

    Default Re: Sending signal to other process?

    You can also communicate through a pipe or using PostMessage() which is a WinAPI call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Sending signal to other process?

    I will try PostMessage() and its counterpart GetMessage() (right?).

    I have another idea: Using a QSharedMemory and placing a flag in it. The new app sets the flag to true when the first app has to quit. The first app waits for the flag to be set to true (non-blocking of course).

  4. #4
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sending signal to other process?

    I don't know if you already solved your issue, but just in case...

    Quote Originally Posted by Boron View Post
    I will try PostMessage() and its counterpart GetMessage() (right?).
    Well, you don't really need GetMessage(): the msg posted from the other app gets routed to the first app msg loop directly by Windows, so you just need to add an additional case in the first app msg loop switch (or any other similar construct you may have used).

    Note: to use PostMessage(), you need the handle of a window beloging to the target app; if the first app has a window with a specific class and/or title, you may find it with FindWindow().

    The whole is very Windows-specific, though. So...
    I have another idea: Using a QSharedMemory and placing a flag in it. The new app sets the flag to true when the first app has to quit. The first app waits for the flag to be set to true (non-blocking of course).
    This sounds much more platform-independent, fast and simple!! I would try it first.

    Ciao,

    M.

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. sending data over signal
    By gyre in forum Newbie
    Replies: 1
    Last Post: 16th December 2007, 23:10
  4. Replies: 5
    Last Post: 5th November 2007, 10:13
  5. qt network performance
    By criss in forum Qt Programming
    Replies: 16
    Last Post: 24th July 2006, 09:23

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
  •  
Qt is a trademark of The Qt Company.