I have two radio buttons. When clicking one of them it should disable some widgets and activate some other. What should I do for that?
e.g If I check radioButton1 then it should disable a lineEdit instantly and if I check radioButton2 it should enable the first line edit and disable lineEdit2.
All this in real time.
Without having much to go on at the moment, a general answer would be the following:
Handle the appropriate signal of your radio buttons. Using this signal you can trigger a method/loop where you set your widgets to be disabled using setEnabled(false).
Given your situation you could have something similar to the following two methods, which you call depending on the signals you receive:
void OnRadioButton1()
{
lineEdit->setEnabled(false);
lineEdit2->setEnabled(true);
}
void OnRadioButton2()
{
lineEdit->setEnabled(true);
lineEdit2->setEnabled(false);
}
It's pretty straight-forward really. I don't understand where this whole notion of "real-time" comes into play. It's a single response to a single input "event".
Of course, this could just as well be a single method with a specific (boolean) argument or whatever. But given that we're discussing a hypothetical example case here that does not necessarily reflect your real code, this should at least provide you with a bit of an idea.
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