0
votes

I have two Qt apps sharing a memory segment.

enter image description here

I would like to be able to emit a signal from App2 and trigger a slot from App1. First off, I need to use QObject::connect() to link the App2 signal to the App1 slot.

Is there a good way to connect two different Qt processes signals/slots mechanisms? I've stumbled upon the qt-remote-signals library to send remote signals, which is using QDataStream to serialize the object. QSharedMemory uses the same class.

Or should I forget about connecting anything and just simulate a signal/slot behaviour?

  1. Write in the memory segment from App2
  2. Read the segment whenever it changes from App1 (how to know when it is updated?)
  3. Emit a custom signal from App1
  4. Trigger a slot from App1

Does that sound realistic ? I'm new to shared memory.

1

1 Answers

1
votes

As far as I know, you can't connect Signal/Slot between processes. Also you cannot know 'naturaly' if another process have changed a QSharedMemory.

So I think you'll have to simulate it as you said.

  1. Write in the memory segment from App2
  2. App 1 could be checking periodically the segment, to being aware of changes from App 2. Once a change is done, you directly trigger the slot (you don't really need the signal)

If you need an instantly response (without making the App 1 checking time too small) from App1 you could make them comunicate using QLocalSocket/Server or D-Bus, butin that case you could go all in with them and manage all the comunication, making the QSharedMemory unnecesary.