[Qt-interest] boolean field checkbox QTableView
Linos
info at linos.es
Wed Feb 11 09:55:46 CET 2009
Hello,
I have a QTableView with a QSqlRelationalTableModel and i want the boolean
colums to be checkboxes in display and edit, I have searching the forum but i
have not understand the full picture here i think, i have tried two ways to do that:
-Create a QItemDelegate subclass and reimplement the methods createEditor,
setEditorData, setModelData and updateEditorGeometry to represent a checkbox on
edit.
-Create a QSortProxyModel subclass and reimplement flags to add a
Qt.ItemIsUserCheckable on the boolean column an check for Qt::CheckStateRole in
data method to reply with the boolean value of the column.
If i use the sortproxymodel i get the checkbox in display with the correct
values but i still see the "true, false" strings and to change the value i get a
combobox with the values true or false.
If i use the delegate i get the checkbox to edit on doble click but i dont see
checkboxes in display mode, only my well know "true, false" strings.
If i use the delegate and the sortproxymodel i get a checkbox on the left of the
cell on display mode and when i try to change the value i see other checkbox at
the right of the first where i can change the value, after i commit the change
the second checkbox is gone and the left display checkbox shows the change.
Do i have any way to have a checkbox column in display and edit (the same) and
not see the text "true, false"?
Thanks in advance.
More information about the Qt-interest-old
mailing list