Displaying information from a database in model view
Follow these steps to display information from a database on a model view widget:
How to do it…
In this recipe, we will learn how to display multiple sets of data obtained from our SQL database in a model view in our program:
- We will be using the database table called
employee
, which we used in the previous example in Creating a login screen with Qt. This time, we need a lot more data in the employee table. Open up your SQLiteStudio control panel. Add data for a few more employees so that we can display it later in our program:
Figure 12.20 – Add more dummy data to the employee table
- Open Qt Creator, create a new Qt Widgets Application project, and then add the SQL module to your project.
- Open
mainwindow.ui
and add a table widget (not a table view) from Item Widget (item-based) under the Widget box pane. Select the main window on the canvas and click on either...