Qt World Summit: Register Today!

How to loop through only the records that were changed (edited, new, to clear).

  • I'm using OnManualSubmit. Before Recording with submitAll () desire
    make a loop to cycle through only the records that were changed in some way.
    How do I detect those records?.
    For each record I find I need to know if it was: Edited, Added or will be Deleted.
    This is to make a special synchronization information.
    Thank you very much!

  • you could create a record structure that contains a couple of booleans to determine whether or not something was edited, added, or will be deleted.

  • To find out if a record has been changed I tried with isGenerated but I would touch review all records of the table open. However, in some programming languages ​​GETNEXTMODIFIED (function) quickly locate only the records that have been modified without having to review all.

    I need to know the equivalent function in qt and brief example of its use.

  • There is no equivalent single function in Qt. You can iterate over rows and columns with QSqlTableModel::isDirty(). I am not sure how it deals with new or deleted rows.

  • @
    //I created a slot called my_data_edit associated with signal dataChanged:

    model= new QSqlTableModel(this);
    connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(my_data_edit(const QModelIndex&, const QModelIndex&)));


    void Dialog::my_data_edit(const QModelIndex&x, const QModelIndex&) {
    //mark row in a field.

    //I also write a check in add button.

    //Furthermore, in the delete button I add a record in a special table to keep log of deleted records.


Log in to reply