How to uncheck button in QButtonGroup
-
Hi all, I have QButtonGroup, at default all buttons in that group is uncheck, then user press some button, and this button become a checked - this is no problem. But then, in some function, I need to uncheck current button, I try to do like this:
@void myClass::onButtonClicked( QAbstractButton * btn){
if(btn && btn->checked())
btn->setChecked(false);@ but this cod does'nt work. Set this group not exclusive I can't because at one moment I need only one (or no one) button checked. -
-
Tnx 4 help!
-
I have one more question:
how to say button group so I need check my hidden button?
i try that, but it is'nt work :(
@....
QPushButton * nBtn = new QPushButton(this);
myBtnGroup.addButton(nBtn, 0);
...
void myClass::onButtonClicked( QAbstractButton * btn){
if(btn->isChecked()){
QAbstractButton * hidenBtn = m_myBtnGroup->button(0);
hidenBtn->setChecked(true);
return;
}
...
}@ -
I need unckeck button if I(user) click to the ckecked button. That's why I try to do this like theat.
-
@chelock - Your english is fine.... ;-)
The setExclusive is neat.. Kinda a "obvious solution"..
But anyone filed a bug...
Would be neat to have a kinda "required" value or allowNone() or alikepete