Skip to content Skip to sidebar Skip to footer

How Do I Get The Information That The User Has Changed In A Table In Pyqt With Python And Sqlite3

I have a table that comes up on my GUI. The user can edit this table from the GUI. how do I get all of the information that has been edited and update it in the database? The user

Solution 1:

You can do a few different things.

To prevent editing, you can just remove the edit flag for the items you don't want the user to edit

FullName.setFlags(FullName.flags() & ~Qt.ItemIsEditable)

It looks like you're storing the original data (i.e. self.all_data). You could just compare the data in the selected table cells with the original data and only update fields that have changed.

You could also connect to the itemChanged signal for the table widget and keep a running list of all the indexes that have changed since the last refresh

    ...
    self.changed_items = set()
    self.table.itemChanged.connect(self.log_change)

deflog_change(self, item):
    self.changed_items.add(item)

Alternatively, depending on how much control you want, you can also create a QItemDelegate to do all of this.

Post a Comment for "How Do I Get The Information That The User Has Changed In A Table In Pyqt With Python And Sqlite3"