Since you talked about QML I will assume that you work with embedded devices so SQLite is probably the database for you.
Here is an example of how to connect to a database, hope this helps:
Make sure to include
#include <QSqlDatabase>Also add
QT += sqlTo your project file