Welcome Isaac 🎉 🎊
Verify you are not a bot solving the captcha!
Remember to check the documentation page https://doc.qt.io/qtforpython/ and the wiki https://pyside.org if you have some questions.
Ссылка
click to show
click to show
Welcome Victoria Voigt 🎉 🎊
Verify you are not a bot solving the captcha!
Remember to check the documentation page https://doc.qt.io/qtforpython/ and the wiki https://pyside.org if you have some questions.
Ricardohello, everyone! I'm trying to change the state of a checkbox, but it always return as checked. Is there anything wrong if the code bellow?
if isinstance(child, QCheckBox) and child.isChecked() is True:
child.setChecked(Qt.Unchecked)
print(child.isChecked())
I never tried the Qt values there just True/False but it probably yields the same results, right?
ëRiCI never tried the Qt values there just True/False but it probably yields the same results, right?
Correct. I want to clear a form when a cancel/discard button is pressed.
Ricardohello, everyone! I'm trying to change the state of a checkbox, but it always return as checked. Is there anything wrong if the code bellow?
if isinstance(child, QCheckBox) and child.isChecked() is True:
child.setChecked(Qt.Unchecked)
print(child.isChecked())
this is wrong, you need to call child.setChecked(False), or child.setCheckState(Qt.Unchecked)
id 942897553this is wrong, you need to call child.setChecked(False), or child.setCheckState(Qt.Unchecked)
Ohh good catch! setCheckState is good for tristate checkboxes
Hmm this might be a PySide bug... It should probably fail if you pass something other than a boolean, though I'm not sure. Oftentimes you want to coerce something to a boolean.
@cmaureir thoughts?
The issue is calling QCheckBox::setChecked(Qt.Unchecked) doesn't fail (I think it sets the checkbox to checked).
Keith KyzivatHmm seems odd. Try using toggle() method to set the checkbox checked (after you check the value) and see if that works?
Another thing you could try is access the state via the checked property. Afaik that is a property.
I will try that. dbunk , I tried with False before, but it failed as well. I will try again later.
id 942897553what does cb.checkState() return ?
I will try now. Meanwhile, I tried out with the option "exclusive" unchecked and it works. Radio Buttons also fails with same result: setChecked to False takes no effect.
id 942897553can you try cb.setCheckState(Qt.Unchecked) ?
When using Exclusive checkbox, it does not change the checkbox state. Same for radio buttons.