[PyQt] problem with setItemDelegateForColumn and ItemIsUserCheckable

Brian DeWeese brian.deweese at gmail.com
Tue Jun 5 13:28:47 BST 2007

I have a 2 column QTableView where column 0 is checkable and column 1 is
editable.  I've written a custom editor by implement QItemDelegate which is
working fine.  Also, the checkbox in column 0 is also working fine.  But,
unfortunately, not both at the same time.

If I use view.setItemDelegate(myDelegate) than my delegate is called to
create my custom editor and everything about column 1 works correctly.  But
column 0 doesn't work correctly. It is displaying a checkbox with the
correct current value but clicking on it does not call my model's setData()
method or do anything at all as far as I can tell.

If I use view.setItemDelegateForColumn(1, myDelegate) than the checkbox in
colum 0 works but double-clicking on column 1 will ignore my delegate and
create a default editor.

Is this a known bug in either PyQt or Qt itself?  Or am I doing something

I'm using PyQt 4.1.1 with Qt 4.2 on SUSE 10.1.  (BTW, Is there a proper way
to verify that I'm using the versions that I think I'm using?)

Here is my model.flags() method.

    def flags(self, index):
        if not index.isValid():
            return QtCore.Qt.ItemIsEnabled

        if index.column() == 0:
            return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable |
        elif index.column() == 1:
            return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable |

        return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable

Any help would be greatly appreciated.

Brian DeWeese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070605/b55a10c4/attachment.html

More information about the PyQt mailing list