[Qt-interest] QTableView and checkbox
Harry Sfougaris
hsfougaris at gmail.com
Sun May 23 21:26:38 CEST 2010
This seems to have been asked many times, but the replies seem very unclear to me.
I am using an QSqlTableModel that has a boolean field. (My table is a Postgres table)
My issue is that I want to display a checkbox for the boolean field when the model is used in a QTableView (readonly, not editable) .
To start with, I was under the impression that simply assigning the model to a QTableView, would display boolean fields as checkboxes.
Since that is not working (I am getting the text true/false in my column), after some googling I found two possible solution, both of which seem very confusing to me:
One involves using a QSortFilterProxyModel subclass and overriding data() and flags() somehow.
The other involves a QItemDelegate and setting the editor.
I've tried both approaches with mixed results. Can someone please tell me what is the proper way to implement this?
What I'm trying seems overly complicated, for something so seemingly simple.
Should I use a different approach when I want an editable column, and something when I want a readonly column?
Thank you,
Harry Sfougaris
More information about the Qt-interest-old
mailing list