#includeIn this example, QSqlQuery is used to execute a SELECT statement that retrieves all the fields from the "mytable" table, and then loop through the result set using the QSqlQuery::next() function. The package library for QSqlQuery is the "qt5-sql" package.#include int main() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("mydb.db"); db.open(); QSqlQuery query; query.prepare("SELECT * FROM mytable"); query.exec(); while(query.next()) { QString name = query.value("name").toString(); int age = query.value("age").toInt(); // Do something with name and age } db.close(); return 0; }