Problem with the QCheckBox
-
wrote on 19 Jun 2018, 15:08 last edited by letinas
So, when the user ticks the checkbox, I check whether the condition is met or not.
In case the condition is not met, then I reset the checkbox to unticked.
When the user ticks the checkbox again, it really gets ticked, but the signal isn't fired.
Only when the user unticks the ckeckbox again, it will work again.Here are some things that I have tried:
void SLOT_CB_MyCheckbox_STATECHANGED(int state) { if (state && !condition) ui.CB_MyCheckbox->setChecked(false); }
and
void SLOT_CB_MyCheckbox_STATECHANGED(int state) { if (state && !condition) bool oldState = ui.CB_MyCheckbox->blockSignals(true); ui.CB_MyCheckbox->setChecked(true); ui.CB_MyCheckbox->setChecked(false); ui.CB_MyCheckbox->blockSignals(oldState); ui.CB_MyCheckbox->setChecked(false); }
The second code snipped actually worked for some other examples where I needed to set it to some default value in the last line, instead of just
false
.Thanks for the help!
-
Hi,
From a user point of view: why is that check box enabled if the conditions are not met ?
If a checkbox I click on auto-unchecks then it looks like a bug.
-
wrote on 20 Jun 2018, 16:34 last edited by
I totally agree! The user shouldn't be able to check it, if the conditions aren't fulfilled.
I will do it this way. Thanks a lot! :)Could you please explain me, why the signal isn't emitted in the situation I described above?
I couldn't figure it out... -
What does
condition
contain ?
4/4