viewing removed but not submitted rows
Using Qt4.1 QSqlQtableModel
After using "removingRows()" and before submitting it,i want to show the undeleted rows in a TableView or TableWidget. Using the normal way the deleted one is also shown.
Is there a way to distinguish between unchanged, changed and removed rows in a model?
Re: viewing removed but not submitted rows
No. Removed rows are removed from the model. They are just not removed from the database yet until you submit the changes.
What is the "normal way" you mention?
Re: viewing removed but not submitted rows
I think the normal way is that "model->removingRows()", removes the row from the model, the submit removes it from the Database-Table.
Drawing the model in a TableWidget or TableView, the removed row should not be there, but it is!
Re: viewing removed but not submitted rows
Can you provide a minimal compilable example which reproduces the problem?
Re: viewing removed but not submitted rows
Hi wysota,
if cutted some code, which you should show the problem:
//all the rows from the model are drawn
for(int x=0;x<mnModel->rowCount();x++)
{
qry->first();
do
{
for(int y=0;y<qry->record().count();y++)
{
newItem= new QTableWidgetItem(qry->value(y).toString());
tw->setItem(x,y-1, newItem);
}
}while(qry->next());
//removing but not submitting. the user should see the modified tablewidget contents and later submitt all the changes at once.
mnModel->removeRows(currentRow,1);//currentRow=row selected in the tablewidget
//if i'm right, now the row is gone in the model and no changes are made in the Databasetable
for(int x=0;x<mnModel->rowCount();x++)
{
qry->first();
do
{
for(int y=0;y<qry->record().count();y++)
{
newItem= new QTableWidgetItem(qry->value(y).toString());
tw->setItem(x,y-1, newItem);
}
}
}while(qry->next());
// but all the row, even the removed one are shown again
i can#t find a way only to draw undeleted rows.
Do you know away to distinguish between unchanged, changed and/or removed rows in a model(not in a databasetable) while the changed are not comitted yet
Re: viewing removed but not submitted rows
I asked for a compilable example. I understand what your problem is, I just want you to reproduce it with a different, simpler code, so that we can make sure the problem is where you think it is.
1 Attachment(s)
Re: viewing removed but not submitted rows
sorry for being late.
the zipfile contains the source of a running example, based on the QT/demo/books.
pherhaps you have to change the database driver