Results 1 to 12 of 12

Thread: How to allow only one signal to be connected to a QObject's slot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to allow only one signal to be connected to a QObject's slot

    You can put the callback at either end.
    How does having a callback at receiver end will help the receiver know that the signal is emitted (I mean that sender wants to send somting)?

    For a slot you can't really have an equivalent because slots can be called as regular methods.
    Fair reason
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to allow only one signal to be connected to a QObject's slot

    Quote Originally Posted by Santosh Reddy View Post
    How does having a callback at receiver end will help the receiver know that the signal is emitted (I mean that sender wants to send somting)?
    Instead of emitting a signal, one calls a notify method in the callback.

    Anyway I think my solution with an external connection manager is better as it retains the ability to both connect to the signal and to the slot for reasons other than what the OP wants while at the same time containing one-many semantics of a particular set of connections in a neat black box.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to allow only one signal to be connected to a QObject's slot

    Ok, I think there is a missunderstanding, may be my posts was not clear enough. All my posts talk about the the snippet you posted, and not about the callback pattern in general. I know things are possible the way you said.

    Anyway, I get your point.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Replies: 2
    Last Post: 26th August 2011, 08:51
  2. Signal connected to slot (or signal)
    By Althor in forum Newbie
    Replies: 2
    Last Post: 6th July 2010, 10:00
  3. Disconnect slot when another is being connected
    By holst in forum Qt Programming
    Replies: 4
    Last Post: 8th September 2009, 09:49
  4. Replies: 4
    Last Post: 9th July 2009, 12:05
  5. QObject signal/slot not working
    By Msnforum in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2009, 22:50

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
  •  
Qt is a trademark of The Qt Company.