// Create a QSqlQueryModel instance QSqlQueryModel* model = new QSqlQueryModel(); // Write a SQL query to fetch data from a table QString query = "SELECT * FROM employees"; // Set the query to the model model->setQuery(query); // Set the model to a TableView widget ui->tableView->setModel(model);In the above example, a new QSqlQueryModel instance is created and a SQL query is written to fetch data from an "employees" table. The query is then set to the model and the model is set to a TableView widget in the UI. The package library for QSqlQueryModel is the QtSql library.