I am trying to create a table in PySide6 to show data from a database. One of the variables in my database is a boolean variable, and I would like that to show in the table as an editable checkbox, which I can simply click on to switch between True and False values.
This, I would have thought, should be a really easy thing to do, but as far as I can tell, it isn't.
Using QTableView, it appears to be phenomenally complicated. The question of how to do it has been asked many times before on this site and others (eg here), and seems to involve things like defining your own class to replace QTableView or adding a Delegate item for the relevant column, and quite possibly both. It always seems to involve many dozens of lines of code.
It does seem to be a lot simpler using QTableWidget instead of QTableView, and is simply a matter of doing something like this:
tbl = QTableWidget()
tbl.setCellWidget(row, col, QCheckBox())
(looks like you have to iterate through all the rows if you want it to apply to a whole column, but that's not too bad).
However, as I understand it, QTableWidget can't connect to a data model in the same way that QTableView can, so I'd have to write my own code to connect the QTableWidget to the data, and I'm back in "dozens of lines of code" territory.
Is it really that complicated, or am I missing something? It seems like it ought to be a very simple thing to do, but if it is, I haven't yet found the simple way of doing it.
BTW, I'm not yet totally wedded to PySide6. It seems like a nice GUI tool in many ways, but if someone is going to tell me that this is way simpler in Tkinter or wxPython or something like that, then I might be willing to consider switching to a different GUI framework.
Thanks