Bool interprets "false" as "true"
Unsolved
General and Desktop
-
i am getting my checkboxes filled like:
checkbox_1.setChecked(bool(feature["checkbox_1"]))
and after they are getting checked/unchecked i save the changes with:
feature["checkbox_1"] = checkbox_1.isChecked()
now the problem...
before
the values from database are "x" for checked and "NULL" for unchecked. i should try to keep these values in the best case, but im not sure if and how this is possible.
after
checked/unchecked the checkboxes their values from thesecond command
are "true" and "false". when i now uncheck one of the boxes thefirst command
interprets "true" and "false" both as "checked" -
Hi,
It's up to you to "translate" these two non Boolean values to Boolean back and forth.
-
@qtnoob420 Is really not that hard:
checked = False if feature["checkbox_1"] == "x": checked = True
Or shorter:
checked = feature["checkbox_1"] == "x"