Results 1 to 4 of 4

Thread: Connecting signals and slots from different process

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Connecting signals and slots from different process

    Hello!

    There is a task a application of mine does eventually that consumes quite a lot of memory, while the rest of the system has to process lots of other tasks as well. For optimization purposes, I initially decided to create a QThread-based class that would perform this eventual task separately, while sending progressive signals to a QProgressDialog's setValue(int) slot to tell the user how things are going.

    But lately I was thinking about the possibility of moving this task to a different process and control it using QProcess. If I actually end up doing this, how would I connect the signal from the separated process with the QProgressDialog's setValue(int) slot? Is there a way to connect a slot from a given process with a signal from another, child process? Or I would have to implement the communication through a different methodology? In this case, which would it be?


    Thanks,


    Momergil

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Connecting signals and slots from different process

    If you are concerned about the overall system performance, remember that introducing new process is more expensive than starting one additional thread in already existing process.
    I don't know the details of your implementation, but maybe you can just run this task asynchronously with QtConcurrent, without the need to use threads explicitly.
    If you decide to go with QProcess, then no, there is no way to use "connect()" between objects living in two separate processes, you have to use some inter-process communication method, like shared memory, pipes etc. Probably the easiest thing to do would be to write the progress to stdout and read it in "parent" process using QProcess facilities (readyReadStandardOutput () signal and such).

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

    Momergil (7th February 2014)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Connecting signals and slots from different process

    Quote Originally Posted by stampede View Post
    If you are concerned about the overall system performance, remember that introducing new process is more expensive than starting one additional thread in already existing process.
    Hmm, actually my problem is to not overweight the main process, since it will have lots of mathematical and graphical operations to do continuously, and this other taks will be considerably heavy as well. In other words, my goal is related to my main process only.

    I guess I'll have to think more carefully about this then... And do some reading about QtConcurrent

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Connecting signals and slots from different process

    One way to do something very similar to cross process signal/slot is using D-Bus.

    Another option is to use QLocalServer/QLocalSocket and a simple protocol of your own design.

    Cheers,
    _

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

    Momergil (10th February 2014)

Similar Threads

  1. Connecting QML signals with Qt slots
    By KIBSOFT in forum Qt Quick
    Replies: 1
    Last Post: 15th November 2010, 10:18
  2. Replies: 8
    Last Post: 18th July 2009, 16:57
  3. Connecting signals and slots help pls
    By bod in forum Qt Programming
    Replies: 9
    Last Post: 1st July 2008, 16:01
  4. Connecting signals & slots across different threads
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 13:40
  5. Connecting slots/signals in subclassed form
    By qball2k5 in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2006, 17:01

Tags for this Thread

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.