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.
The QPushButton widget provides a command button. More... The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.
Four QPushButton objects are defined as instance variables in the class. First button b1 is converted into toggle button by the statements − Clicked signal of this button is connected to a member method btnstate () which identifies whether button is pressed or released by checking isChecked () property.
Four QPushButton objects are set with some of the above attributes. The example is written in object oriented form, because the source of the event is needed to be passed as an argument to slot function. Four QPushButton objects are defined as instance variables in the class. First button b1 is converted into toggle button by the statements −
In Qt for Symbian, when I call setEnabled (false) on my QPushButton, I expected the button text to automatically turn gray. It does not.
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); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With