PDA

View Full Version : viewing removed but not submitted rows



maxel
25th September 2006, 16:40
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?

wysota
25th September 2006, 18:14
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?

maxel
26th September 2006, 07:16
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!

wysota
1st October 2006, 10:21
Can you provide a minimal compilable example which reproduces the problem?

maxel
3rd October 2006, 13:07
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

wysota
3rd October 2006, 14:36
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.

maxel
6th October 2006, 18:20
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