×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    When we should use Signals and Slots in Qt?

    Hi,
    I know that, using Signal and Slot two object can communicate with each other.
    (Sender, SIGNAL(mySignal()), Reciever, SLOT(mySlot());

    I know two use of this
    1) If we have callback then we can use this approach
    2) If we have UI Components, in that case we can also use this.

    Any other place for its usage ?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,175

    Re: When we should use Signals and Slots in Qt?

    To put it in very simple way, I would say: You would use signals and slots when ever you are interested on getting notifications.

    You could also use callbacks, if you think it is easier for you, though signals & slots often gets the thing done better and easier in the end.

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: When we should use Signals and Slots in Qt?

    Well, you MUST use signals/slots for UI -- there's essentially no other way. And if you are running some sort of a timer you will likely use signals/slots with that. And if you do anything with asynchronous tasks, signals/slots is a good way to communicate between them (at least in some circumstances).

    Otherwise, you'll occasionally find use for signals/slots but there's no real obvious place to use them. As you become familiar with the concept you may "invent" a few more uses, but there's no need to force yourself to use them -- at some point it just makes the code more obscure and complicated.

  4. #4
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    Re: When we should use Signals and Slots in Qt?

    Yes, got it...

Similar Threads

  1. Replies: 5
    Last Post: 2010-11-05, 19:59
  2. Replies: 4
    Last Post: 2010-10-05, 07:09
  3. signals and slots
    By prathibha83 in forum Qt
    Replies: 3
    Last Post: 2010-06-21, 18:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×