Matthew Hoggan
Matthew Hoggan

Reputation: 7604

Get QObject Which Called Slot

I need a way to find out which widget was responsible for calling a slot via a signal. This is assuming that I have multiple widget's signals connected to the same slot within my application.

QSignalMapper seems like a valid answer, but I can't figure out how to get the object that triggered the signal to be passed into my slot.

Upvotes: 2

Views: 911

Answers (1)

Arnold Spence
Arnold Spence

Reputation: 22282

From within any slot handler, QObject::sender() will return a pointer to the object that sent the signal.

Upvotes: 6

Related Questions