[Qt-interest] Qt signaling smarts...

Gordon Schumacher gordon at rebit.com
Tue Nov 24 18:52:20 CET 2009


BRM wrote:
> Is the Qt Signal/Slot mechanism smart enough to figure out that the thread1 could be sending directly to thread2, and bypass the mainProgram signal altogether (since it's all just signals triggering each other)?
> OR is it at least smart enough that it will not invoke the event loop in mainProgram when delivering the signal from thread1 to thread2?

I'm gonna go out on a limb here and say "no", only because it would not
only need to know that there's a signal "chain" there, but also that
nothing else has connected to thread1's signal (because otherwise it
would need to fire it anyway).

(Thiago, please don't throw anything at me here...)  If you were gonna
be *really* clever about it, you could perhaps do something like:

1. Connect thread1's signal to a "special" slot in mainProgram called
something clever like forward().
2. The forward() function, when called, disconnects sender() from
forward() and connects it to thread2()'s slot instead.

Yeah, it's kinda ugly, but... hmm.



More information about the Qt-interest-old mailing list