Skip to content

ui: Migrate CheckBoxes to use binary state functions setChecked/isChecked#121

Merged
tridge merged 1 commit into
dronecan:masterfrom
joshanne:pr/update-checkbox-check-methods
Mar 29, 2026
Merged

ui: Migrate CheckBoxes to use binary state functions setChecked/isChecked#121
tridge merged 1 commit into
dronecan:masterfrom
joshanne:pr/update-checkbox-check-methods

Conversation

@joshanne

@joshanne joshanne commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Various points in the code make use of Tri-state functionality (ie. setCheckState()/checkState()).

In working to migrate the tool to PyQt6, the checkState() returns and enum, and the enum CheckedState.Unchecked is not considered Falsy.

What that means is if chkbox.checkState() always returns True.

The checkState functionality allows us to make use of a PartiallyChecked state, which is never used inside the codebase - so let's just use the binary states.

# In PyQt6...
>>> from PyQt6.QtCore import Qt
>>> print(f"{bool(Qt.CheckState.Unchecked)=}")
bool(Qt.CheckState.Unchecked)=True
>>> print(f"{bool(Qt.CheckState.PartiallyChecked)=}")
bool(Qt.CheckState.PartiallyChecked)=True
>>> print(f"{bool(Qt.CheckState.Checked)=}")
bool(Qt.CheckState.Checked)=True

This differs from PyQt5 where:

# In PyQt5...
>>> import PyQt5
>>> from PyQt5.QtCore import Qt
>>> print(f"{bool(Qt.CheckState.Unchecked)=}")
bool(Qt.CheckState.Unchecked)=False
>>> print(f"{bool(Qt.CheckState.PartiallyChecked)=}")
bool(Qt.CheckState.PartiallyChecked)=True
>>> print(f"{bool(Qt.CheckState.Checked)=}")
bool(Qt.CheckState.Checked)=True

Needed to resolve Issue #107

…cked

Various points in the code make use of Tri-state functionality (ie. setCheckedState()/checkedState()).

In working to migrate the tool to PyQt6, the checkedState() returns and enum, and the enum CheckedState.Unchecked is not considered Falsy.

What that means is `if chkbox.checkState()` always returns True.

The checkState functionality allows us to make use of a PartiallyChecked state, which is never used inside the codebase - so let's just use the binary states.
@tridge tridge merged commit 09f36e7 into dronecan:master Mar 29, 2026
4 checks passed
@joshanne joshanne deleted the pr/update-checkbox-check-methods branch March 30, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants