Once we have the database configured and running, we can now connect to it using the same functions regardless of whether it is local or a remote database. Now, let's take a look at writing code to connect to a database, whether local or remote.
Databases are either locally available, which usually means on the same machine, or accessed remotely over a network. Connecting to these different databases using Qt is essentially the same. Not all databases support remote access.
Let's begin by using a local database.
To use the sql module, we need to add sql to the profile:
QT += sql
To connect to a database in Qt, we need to use the QSqlDatabase class.