Results 1 to 7 of 7

Thread: viewing removed but not submitted rows

  1. #1
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?

  3. #3
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: viewing removed but not submitted rows

    Can you provide a minimal compilable example which reproduces the problem?

  5. #5
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  7. #7
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.