Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Advance Signals and Slots
Forum Updated to NodeBB v4.3 + New Features

Advance Signals and Slots

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arukas
    wrote on last edited by
    #1

    Hello-

    If I have several widgets connected to a slot. I'd like the slot to know what widget triggered it by passing something like an integer. I looked in the help files and there was a mention of a signal mapper? Is that the best way and/or only way?

    -Arukas

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on last edited by
      #2

      QSignalMapper itself is quite good to use in your considering design, though using QObject::sender() function to know the source of signal in your slot is quite handy.

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Yes, [[doc:QSignalMapper]] has been designed for this scenario. I prefer it over using QObject::sender(), because it makes it a bit clearer what happens IMHO. The method you create to actually do the work, will have the parameter identifying the widget already. Even if you call it directly, or through some other signal/slot connection, it will still work. The sender() approach does not have these saveguards, and you cannot judge from the function signature what will happen exactly. At the very least, you will need to check that sender() returns something sensible before trying to dereference it in your slot.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Thanatos.jsse
          wrote on last edited by
          #4

          Thanks...
          It's exactly what I've looking for.

          BR,

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved