In Qt to represent table fields, which involve foreign keys to other tables database, QSqlRelationalTableModel can be used, which is a more advanced version QSqlTableModel class, which was considered in the
This class allows you to set relationships between tables and substitute values in the representation of the table formed by the values of the connected tables.
This article discusses the option of two tables. One table contains information about the devices (host name and IP address), and the second table ID of the device, which in the second table to be substituted host name and IP address of the device, respectively.
Project Structure for QSqlRelationalTableModel
The project for this tutorial is a modified version of the preceding Article and remains unchanged.