In this section, we will look at how we can store and retrieve data in Qt. In particular, we will work out a solution for yet another requirement.
Management has taken a look at what we have done so far with our BigProject, and they like it. Mostly. They did find something to ask about—Where is the old data? When you start the program, there is no history. Why don't we keep the old data so that we can see it? From that, and the conversations that followed, comes a new requirement:
Req. 7: The system shall maintain a history of readings across power cycles.
There are a lot of ways we could store data, but we are here to learn about how to use a database and Qt's database access methods. QSqlDatabase provides a generic interface to several database backends, including MySQL (and MariaDB), SQLite, IBM DB2, PostgreSQL, and generic ODBC (for example...