Hello
I have written a custom delegate to display dates in a particular format and then save them when entered this way. The problem is that it appears to work randomly. Either it saves the date correctly to a sqlite3 database or I get a messagebox pop up with a Microsoft 'python.exe has encountered a problem' message. I also get 'Process terminated with an exit code of -1073741819' in the IDE OS Commands tab (Wing).
This is the setModelData function from the delegate.
def setModelData(self, editor, model, index):
if index.isValid():
if DATATYPE[self.parent.dataType] == 'SURVEY' and index.column() in [7, 8]:
model.
setData(index,
QVariant(QDate.
fromString(str
(editor.
text()),
'd/M/yyyy'))) else:
def setModelData(self, editor, model, index):
if index.isValid():
if DATATYPE[self.parent.dataType] == 'SURVEY' and index.column() in [7, 8]:
model.setData(index, QVariant(QDate.fromString(str(editor.text()), 'd/M/yyyy')))
else:
QSqlRelationalDelegate.setModelData(self, editor, model, index)
To copy to clipboard, switch view to plain text mode
Thanks in advance.
Bookmarks