Inconvenient Behaviour: QSqlTableModel.removeRow()
After updating PyQt version 4.8.5 to 4.9.4, QSqlTableModel.removeRow() has the following behavior:
- Return True.
- verticalHeaderData changed to “!”.
- Row content erased (Record fields become blank in the QTableView)
- Calling submitAll() works as expected.
- I tried to install a fresh copy of Python v2.7 & PyQt v4.9.4 to another machine but the problem persist.
- Downgrading the PyQt version to 4.8.5 seems to solve the problem.
Code: (This is the exact code used for testing on both versions)
- mw = QMainWindow()
- model = QSqlTableModel(None, connectionManager().getConnection())
- tv = QTableView(mw)
- bt = QPushButton("Delete", mw)
- bt.clicked.connect(lambda: model.removeRow(tv.currentIndex().row()))
- If some can help providing me a previous PyQt ver(4.9.1 or 4.9.2 or 4.9.3) this might solve the problem for the current time.
Appreciate any kind of help.
sorry Andre, i will try to explain better now.
the problem is: Why calling QSqlTableModel.removeRow() erase the row content in the view and model. (so, calling record.field().value().toString() for the removed row —without calling submitAll()— returns empty string for all fields.!!)
doing so with PyQt v4.8.5 will keep the row contents untouched until i call submitAll() for actual deletion.
Thanks for your patience.