QSqlTableModel(): Add an empty record with an auto-increment column
Unsolved
Qt for Python
-
Hello,
the first column of my table is auto-increment.
I want to add an empty record to the end of the table.Here is my attempt:
def add_record(self): record = self.table_model.record() record.setValue(self.table_model.rowCount()+1, '','','') self.table_model.insertRecord(self.table_model.rowCount(), record)
When executed, the program crashes with the following error message:
Process finished with exit code -1073740791 (0xC0000409)Question:
How does it work without a program crash? -
sorry, it is easy:
def datensatz_hinzufuegen(self): self.table_model.insertRow(self.table_model.rowCount())