I have a QTableView
showing a data from a custom model. I have a QItemDelegate
for the edition on each of the cells. One column of the view has a custom widget comprised by a QLineEdit
and a QCheckBox
. When I click on the cells of this column the editor is shown and it works, but it doesn't fit the table cell. Moreover, when I enlarge a row and click on the cell, I can see the data of the cell behind the widget.
Is there a way that my widget behaves like a normal editing widget for a QItemDelegate
on the view? i.e when created it uses all the vertical space of the cell?
This is my widget (simplified):
class MyWidget(QtGui.QWidget):
def __init__(self, parent = None):
super(MyWidget, self).__init__(parent)
self.lineEdit = QtGui.QLineEdit(parent)
self.checkBox = QtGui.QCheckBox(parent)
self.checkBox.setChecked(False)
self.gridLayout = QtGui.QGridLayout(self)
self.gridLayout.setSpacing(3)
self.gridLayout.addWidget(self.lineEdit, 0, 0)
self.gridLayout.addWidget(self.checkBox, 0, 1)
My delegate (simplified):
class MyDelegate(QtGui.QItemDelegate):
def __init__(self, parent = None):
super(MyDelegate, self).__init__(parent)
def createEditor(self, parent, option, index):
return MyWidget(parent)
def setModelData(self, editor, model, index):
pass
def setEditorData(self, editor, model, index):
pass