Solved:Qt:How to make the checkbox‘s “isChecked()” state return back unchecked state with code?
-
I want to remove the tick of checkbox which is selected by the the user with code to implement some functions.Such the user can select the checkbox again.How I can do it using code?
the code statements look like the followed :
if(ui-> checkBox_HB->isChecked())
{
Here I want make the checkBox_HB return back unckecked state(remove the tick)
} -
Hmmm,
maybe try to connect to the signal: "toggled":http://qt-project.org/doc/qt-4.8/qabstractbutton.html#toggled or "stateChanged":http://qt-project.org/doc/qt-4.8/qcheckbox.html#stateChanged to figure out when the checkbox was toggled?
Then You can use the "setCheckState":http://qt-project.org/doc/qt-4.8/qcheckbox.html#setCheckState with Qt::Unchecked value( "CheckState enum":http://qt-project.org/doc/qt-4.8/qt.html#CheckState-enum )
hope this will help You,
poorBob
-
[quote author="Badger" date="1404729699"]You can also do QCheckBox::setChecked(bool checked) function (from QAbstractButton) if you do not care about the other checked states apart from checked and unchecked[/quote]
OK,it works well,and thank you very much ! I'm a freshman to study Qt by myself.I indeed have to read more materials about Qt assistance, maybe I can solve the problem by myself.
-
Thanks a lot. I’m a freshman to study Qt by myself.I indeed have to read more materials about Qt assistance, maybe I can solve the problem by myself. Thank you once more!
[quote author="poorBob" date="1404724025"]Hmmm,maybe try to connect to the signal: "toggled":http://qt-project.org/doc/qt-4.8/qabstractbutton.html#toggled or "stateChanged":http://qt-project.org/doc/qt-4.8/qcheckbox.html#stateChanged to figure out when the checkbox was toggled?
Then You can use the "setCheckState":http://qt-project.org/doc/qt-4.8/qcheckbox.html#setCheckState with Qt::Unchecked value( "CheckState enum":http://qt-project.org/doc/qt-4.8/qt.html#CheckState-enum )
hope this will help You,
poorBob[/quote]