Results 1 to 10 of 10

Thread: signals and slots between 2 Apps?

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb signals and slots between 2 Apps?

    Problem Statement:

    You have 3 buttons layed out in one window/app A. You have a single LineEdit in a completely different window/app B. When the user clicks any Button in A, the Button name should be displayed in the LineEdit in B. (Apps A & B are independent of each other...i.e. NOT descendants of any window except the root window ofcourse).

    Now, inorder to achieve this, should i have a separate "intermediate" non-gui Widget acting as a bridge or is it also possible to do so directly?

    Thanks

    Nupul

  2. #2
    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: signals and slots between 2 Apps?

    It's not Window$. You can't pass messages between apps. You have to use some other mechanism (like sockets, message queues, shared memory or other IPC mechanism -- probably X protocol has something of its own there too) -- of course both applications have to be aware of that.

  3. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signals and slots between 2 Apps?

    Quote Originally Posted by wysota
    It's not Window$. You can't pass messages between apps. You have to use some other mechanism (like sockets, message queues, shared memory or other IPC mechanism -- probably X protocol has something of its own there too) -- of course both applications have to be aware of that.

    What do you suggest I can use w.r.t. Qt to achieve this...


  4. #4
    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: signals and slots between 2 Apps?

    It depends what do you want to achieve and in what environment. Sockets (preferably Unix Domain) and named pipes or some layer over sockets (Sun RPC, Corba, etc.) are probably the most portable, message queues probably the most universal and shared memory probably the fastest but most crude...

    You can always use higher level mechanisms like dcop or dbus.

  5. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: signals and slots between 2 Apps?

    could you be more specific w.r.t. the example i gave at the start of the thread...on SuSe 10 KDE 3.2/Gnome 2.2

  6. #6
    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: signals and slots between 2 Apps?

    Quote Originally Posted by nupul
    could you be more specific w.r.t. the example i gave at the start of the thread...on SuSe 10 KDE 3.2/Gnome 2.2
    No, I can't. It can be done with any of those. The simplest way probably with dcop, but you need to implement dcop infrastructure for your Qt-only apps. The least code (in this particular case) probably with sockets or message queues.

    You have to look at each of those solutions and decide which one suits you best.

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

    nupul (10th April 2006)

  8. #7
    Join Date
    Jan 2006
    Location
    germany
    Posts
    75
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signals and slots between 2 Apps?

    if your only using it in unix, then i would recomend making a kde app and using dcop.
    if it is not important a quick and dirty solution would be just writing the information to a file, that is monitored by the other app. (you could implement read operations with a qtimer)
    Quote Originally Posted by Bertolt Brecht
    What is the robbing of a bank compared to the founding of a bank?

  9. #8
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: signals and slots between 2 Apps?

    Quote Originally Posted by soul_rebel
    if your only using it in unix, then i would recomend making a kde app and using dcop.
    Doesn't that make the system dependent on the underlying KDE? I wish to make it run on every linux distro!

    if it is not important a quick and dirty solution would be just writing the information to a file, that is monitored by the other app. (you could implement read operations with a qtimer)
    I can't do this, since the change in data has to reflected immediately!

    Nupul

  10. #9
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signals and slots between 2 Apps?

    Quote Originally Posted by nupul
    I can't do this, since the change in data has to reflected immediately!
    Immediately? There's no such thing :-) If it's just a question of updating the GUI, checking the file say 50 times per second ought to be enough, users will thing the application is reacting immediatly.

  11. #10
    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: signals and slots between 2 Apps?

    And you can use some file alternation monitor to help you.

    Or provide a controller application (so something like fam) which will be notified (for example by a unix signal) that a file changed and will "emit" a unix signal to all other applications "connected" to that file. Then it's just a matter of handling such a signal in your apps. No need to implement such a loop in every app then.

    BTW. Does "immediately" mean 1 second, 0.1 second, 0.01 second or what?

Similar Threads

  1. Signals and Slots Problem
    By GenericProdigy in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 09:06
  2. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  3. Problem with SpinBox signals and slots
    By ramstormrage in forum Newbie
    Replies: 4
    Last Post: 2nd May 2008, 01:45
  4. signals and slots in plugins
    By anderl in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 13:57
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.