Hello,
i am trying to subclass QSqlQueryModel to write with it, i need this
because not qsqltablemodel or
qsqlrelationaltablemodel fills my needs, i would like to do joins and insert in
multiple tables, i have
implemented "flags" and "setData" methods and it works ok now, i have made a
"refresh" method to reload the
contents on update because tableView not reload them with datachanged signal
and all works ok but now i am
trying to implement insertrow or insertrows without luck, this is the code i am
using now:
this in model:
def insertRows(self, position, rows=1, index=QModelIndex()):
self.beginInsertRows(QModelIndex(), position, position + rows - 1)
setdataquery = QSqlQuery(self.cursor)
setdataquery.exec_(QString("INSERT INTO SCHEMA.FAKE (FAKE1, FAKE2,
FAKE3) VALUES (4, 2, 'PEPITO')"))
self.endInsertRows()
self.dirty = True
return True
this in qdialog:
def addRecord(self):
row = self.querymodel.rowCount()
self.querymodel.insertRows(row)
index = self.querymodel.index(row, 0)
self.tableView.setCurrentIndex(index)
self.tableView.edit(index)
After execute this method i can view the new row in table view but i get this
in stdout.
edit: index was invalid
edit: editing failed
I have test the row number rowCount() assign and it is ok, i dont know how to
fix this, anyone can help me please?
PD: I get original snippet and the idea about subclass QSqlQueryModel in the
really excellent book "Rapid GUI
Development with Python-PyQT".
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt