Introduction to Model/View Programming

Understand how we use model/view programming with PyQt to manage databases.

We'll cover the following

Creating the application

Signals and slots facilitate communication between the models, views, and delegates. The model uses signals to alert the view to data changes. The view produces signals that reveal details about how a user engages with objects. While editing an item, the delegate emits signals to let the model and view know how the editor is feeling. The following program demonstrates how to use model/view programming to show a table view of the data in a tiny CSV file.

First, we import the necessary classes such as QTableView from the QtWidgets module, and QStandardItemModel and QStandardItem from QtGui. The item-based model we require to deal with the data is provided by QStandardItemModel, and QStandardItem will give the items utilized in the model.

Get hands-on with 1200+ tech skills courses.