App crashes on QCheckBox.setChecked()

  • I ran into a very strange issue. There was some code including some QCheckBox.setChecked(True) calls for the checkboxes added to the context menu.
    Everything worked fine.
    Then I changed an unrelated part of the code and suddenly that code stopped working - the app simply crashes with no error, I confirmed that this happens on the line with setChecked(True).
    The app also crashes silently when I check such checkbox manually in the context menu.

    My code is too big to post it here. Is there any way to debug what happens behind the scenes in PySide6? Any idea why setChecked() could crash?

    I tried running setChecked() on other checkboxes which are in the layout of the window, and it worked fine, and they can also be manually checked/unchecked.

  • Lifetime Qt Champion

    @midnightdim Did you debug the app to find the issue? Do you have a stack trace after crash? Are any slots connected to the problematic check boxes and if so what is done there?

  • @jsulm Yes, I did debug it and there was no stack trace, the app just crashed silently.
    But your reply gave me a good hint. I checked the connected slot and found that it uses the index of the old model while it should have been switched to a new proxy model. This solved the issue.
    Thanks a lot for the tip!

Log in to reply