How to do it...

Follow these steps to display information from a database on a model view widget:

  1. We will be using the database table called employee, which we used in the previous example, Creating a login screen with Qt. This time, we need a lot more data in the employee table. Open up your web browser and log into your phpMyAdmin control panel.

Add data for a few more employees so that we can display it later in our program:

  1. Open Qt Creator, create a new Qt Widgets Application project, and then add the SQL module to your project.
  2. Open mainwindow.ui and add a table widget (not a table view) from Item Widget (Item-Based) under the Widget ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.