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:
QSqlDatabase db = QSqlDatabase::addDatabase("SQLITE");
db.setDatabaseName("path/to/database.db");
db.open(); //This will create the database if it doesent exist
Make sure to include
#include <QSqlDatabase>
Also add
QT += sql
To your project file