pythonpyqtqcheckbox

How can I disable a QCheckBox WITHOUT triggering an event?


I am wondering if there is anyway to disable (setCheckState) on a check box (QCheckBox) in pyqt "WITHOUT" triggering an event? So it is simply a display change with the checkbox now unticked but not triggering the method I have it connected to. Thanks for any help.

Would love a basic example if possible.


Solution

  • You can simply block signals just before disabling the QCheckBox, and re-enabling them just after. Assuming chk is your QCheckBox object just do:

    chk.blockSignals()
    # then you change the checkbox as you want
    chk.unblockSignals()