Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED]How to get emitter of a signal in the slot?

    General and Desktop
    4
    5
    40358
    Loading More Posts
    • 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.
    • W
      wecing last edited by

      Hi,

      Currently I have five QListEdit widgets in a widget of my program.
      I need to connect their editingFinished() signal to a shared slot, but they have to be distinguished inside the slot.

      I guess it's impossible to get emitter of a signal in Qt, but writing five clue slots which will call the shared slot with an extra parameter is too ugly.

      So, any ideas?

      UPDATE: Nevermind. I just found the "Advanced Signals and Slots Usage" section in "Signals & Slots".

      1 Reply Last reply Reply Quote 0
      • R
        rich last edited by

        I hope you've found QSignalMapper.

        1 Reply Last reply Reply Quote 0
        • A
          Anticross last edited by

          QObject::sender() will return you a pointer to signal sender when you call it from the slot.

          1 Reply Last reply Reply Quote 3
          • W
            wecing last edited by

            Thanks guys, but both QSignalMapper and QObject::sender() are referred in the section I mentioned...
            http://developer.qt.nokia.com/doc/qt-4.8/signalsandslots.html#advanced-signals-and-slots-usage

            1 Reply Last reply Reply Quote 0
            • G
              goetz last edited by

              [quote author="Anticross" date="1325161551"]QObject::sender() will return you a pointer to signal sender when you call it from the slot.[/quote]

              Be aware that sender() returns a null pointer, if the slot is called directly (i.e. not using a signal/slot connection).

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply Reply Quote 1
              • First post
                Last post