Results 1 to 6 of 6

Thread: Signals and Slots question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2006
    Posts
    23
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Signals and Slots question

    wysota, When I look at the docs for QSignalMapper I believe here llies the solution to the problem I was describing. Apparently, when a widget is created I can set a mapping to it from the "emitter" based on the widgets id so that signals from the "emitter" are mapped to the appropriate widget. I will "connect" to all the widgets but only send messages to their intended destination, which is the desired operation. In the QSignalMapper "Detailed Description" it examples using QSignalMapper to setmappings for a group of buttons to signal a slot with eachs buttons text id thus bundling the buttons signals. What I'm wanting to do is like the inverse of that. Do you agree my conclusions in this or have I missed the point? BTW, I'm thinking that the "emitter" and widgets will run in their own threads, hence the desire for signals/slots. Thanks again for your insights....

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

    Default Re: Signals and Slots question

    QSignalMapper does a many-to-one mapping and as you said, you want the opposite. The code I've written in the previous post more or less does exactly that. It just isn't thread safe, so if you wish to use threads for your receivers, you need to modify it. I would even suggest to use custom events instead of signals and slots, this way instead of rcv->receive(...) you'd simply call QCoreApplication::postEvent(rcv, new MessageEvent(...)). Then it's just a matter of reimpementing customEvent() to handle the event and implementing the custom event class (MessageEvent).

  3. #3
    Join Date
    Nov 2006
    Posts
    23
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Signals and Slots question

    wysota, this discussion is most helpful and enlightening for me. I'll take a look at your suggestions. Again, thanks very much for your insights....

Similar Threads

  1. Signals and Slots (with structure as parameters)
    By vishwanath in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:14
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.