[PyQt] Crash in TableView cell edit

Phil Thompson phil at riverbankcomputing.com
Tue May 26 11:51:14 BST 2009


On Tue, 26 May 2009 16:33:51 +0700, Alexandr N Zamaraev <tonal at promsoft.ru>
wrote:
> [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]

You aren't keeping references to your delegate or editor factory.

I'll change it so the reference is kept automatically.

Phil


More information about the PyQt mailing list