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. [SOLVED]How to get emitter of a signal in the slot?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 41.7k Views
  • 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 Offline
    W Offline
    wecing
    wrote on last edited by
    #1

    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
    0
    • R Offline
      R Offline
      rich
      wrote on last edited by
      #2

      I hope you've found QSignalMapper.

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

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

        1 Reply Last reply
        3
        • W Offline
          W Offline
          wecing
          wrote on last edited by
          #4

          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
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            [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
            1

            • Login

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