I created lots of QPushButtons, added clicked signal and a slot name deneme()
to all of the buttons with QT DESIGNER
and the thing I want to do is; when I clicked any button, some operation should be done and lastly the button should be disabled but we do not know which button is clicked. I know I can disable the buttons with setEnabled()
and isEnabled()
but I do not know how to disable them.
If I understood correctly you connected various QPushButtons
to the same slot. Inside of the slot deneme()
you want to know which of the buttons was clicked
.
You can do something like:
void deneme() {
QPushButton * b = qobject_cast<QPushButton *>(sender());
if (b) {
if (b == button1) { //button1 clicked
//doSomething();
}
else {
if (b == button2) {
//doSomething();
}
}
b->setEnabled(false);
}
}