To display the data in a widget with an arbitrary use
class. To work with this widget is still required model for presentation.
, but the data is not already substituted
, and various arbitrary objects. For example
. Or in the dialog box to add records with which to work in this article.
Thus, the problem is as follows. Write a program that displays a list of computers in the table, and each computer has three data fields:
Имя Хоста, IP-адрес
There should also be a button to display the dialog box, through which we can add a new device to the table. Also, we should be able to edit the records through the same dialog box.
Project structure of QDataWidgetMapper
The project is created as an application Qt Widgets, where the following files are created:
- header file of the main application window;
- source code of window;
- the main source file from which the application starts;
- form of the main application window;
- header file of helper class to be used for information that is placed in a database;
- source code of helper class file to be used for information that is placed in a database;
- header file dialog to add or edit entries;
- source file dialog box to add and edit entries;
Note. Most of the interface is created in the designer, so as not to clutter up the main logic code superfluous information. In fact it is only a matter of taste and habit.