PDA

View Full Version : Signals and Slots between two different classes



dsab123
26th June 2012, 20:17
I'm dealing two classes right now, class A and class B. an instance of class A and B each communicated together with signals and slots quite well.
I am now attempting to have two other instances of class B; for my application to work, class A will need some way to send a signal to only one instance of class B as opposed to the case where there is just one instance; is there any efficient way to do this without creating a whole new set of signals/slots for A?

thanks.

Added after 49 minutes:

I think QSignalMapper is just what I was looking for.

I should be able to thank myself.

Lesiok
27th June 2012, 07:14
I do not understand what your problem. Signals and slots connect between instances and not classes. So no matter how many instances of the class B exists.

Ali Reza
29th June 2012, 09:32
you can add a static member to class B for example static bool flag=false; then in constractor of class B add this implimentation:

if (flag==false)
connect(your signal and slot)
flag=true;
with this implimentation only first object created class B connect.
Have fun