PySide6 mapper not storing checkbox state in SQLite

I have a table model which has a mapping for the database fields and everything seems to work well when I call self.model.submitAll() but there is one slight hiccup…

I just can’t get the state of any checkbox to store in the DB.

The mapping works great when it loads a record and the checkbox will reflect the correct state when the record has a 0 (zero) or 1 in the column, but if I change the sate of the checkbox it does not get updated in the DB.

This is the mapping line:

self.mapper.addMapping(self.match_exact_checkBox, 5)

The SQLite DB has the field type set as text and displays the correct checkbox state if it contains any of the following:
0 or 1 or True or False

It just won’t update in the DB if I use:


What am I doing wrong?

This problem also exists when using comboBox widgets which are mapped to the db.

Just wanted to let you all know that I found the answer to the problem.

In the .ui file, if you set the focusPolicy of any checkbox and/or combobox to be StrongFocus, everything works as it should.

The mapping works so if I change any checkbox state or select a different item in any combobox, the data get written back to the SQLite db as I would have hoped in the first place.

Not sure if that is the “best” way to do things, but it works and I am happy with the results.