Results 1 to 3 of 3

Thread: Signals and Slots between two different classes

  1. #1
    Join Date
    May 2012
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Signals and Slots between two different classes

    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.
    Last edited by dsab123; 26th June 2012 at 20:17.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,508
    Thanked 277 Times in 272 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signals and Slots between two different classes

    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.

  3. #3
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: Signals and Slots between two different classes

    you can add a static member to class B for example static bool flag=false; then in constractor of class B add this implimentation:
    Qt Code:
    1. if (flag==false)
    2. connect(your signal and slot)
    3. flag=true;
    To copy to clipboard, switch view to plain text mode 
    with this implimentation only first object created class B connect.
    Have fun
    Life is about making the right decisions and moving on.

Similar Threads

  1. Accessing slots of other classes
    By papillon in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2011, 06:24
  2. Replies: 5
    Last Post: 17th November 2010, 17:29
  3. Signals/slots between classes
    By been_1990 in forum Qt Programming
    Replies: 19
    Last Post: 27th November 2009, 13:04
  4. signal/slots in template classes
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2006, 18:28
  5. Signals and Slots between 2 classes
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2006, 00:34

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.