E
E
Egorithm2020-06-08 12:55:48
Qt
Egorithm, 2020-06-08 12:55:48

Qt. How to get a pointer to the widget that emitted the signal in the slot?

There can be any number of buttons, and they are created dynamically. Naturally, they connect to the same slot. How can I get a pointer to the QPushButton that emitted the signal? Or, if not, how can this problem be solved differently?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ighor July, 2020-06-08
@EgoRusMarch

QPushButton *button = qobject_cast<QPushButton*>(sender());

A
Alexander Ananiev, 2020-06-08
@SaNNy32

QObject* obj = sender();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question