The form view is useful when you want to traverse the records one-by-one and perform some modifications to it. In this section, we will see how to create a dialog form that displays the records one-by-one and also learn about how to add, edit, and delete records using the form dialog. We will use the same
employee table created in our previous example.
We will not discuss the layout used in this program as our main aim is to discuss the form view. The model is created using
QSqlTableModel and set the sort factor with the column
first_name in the ascending order:
self.model = QSqlTableModel(self) self.model.setTable("employee") self.model.setSort(FIRST_NAME, Qt.AscendingOrder) self.model.select()
Next, we set the mapping of the form values ...