[PyQt] Crash in TableView cell edit

Alexandr N Zamaraev tonal at promsoft.ru
Tue May 26 10:33:51 BST 2009


[code=python]
from PyQt4 import QtCore, QtGui

class EditorFactory(QtGui.QItemEditorFactory):
   pass

def createTv():
   tv = QtGui.QTableView()
   model = QtGui.QStandardItemModel(4, 2, tv)
   tv.setModel(model)

   delegate = QtGui.QStyledItemDelegate(tv)
   delegate.setItemEditorFactory(EditorFactory())
   tv.setItemDelegate(delegate)

   for row in range(4):
     for column in range(2):
       index = model.index(row, column, QtCore.QModelIndex())
       model.setData(index, QtCore.QVariant((row+1) * (column+1)))
   return tv

if __name__ == '__main__':
   import sys
   app = QtGui.QApplication(sys.argv)
   tableView = createTv()
   tableView.show()
   sys.exit(app.exec_())
[/code]


More information about the PyQt mailing list