I've got a problem:
Connected to the SQLite database, written a request
#include "schedule_edit.h"
#include "ui_schedule_edit.h"
#include <QComboBox>
#include <QtSql>
#include <QMessageBox>
#include <QSqlError>
#include <functions.h>
#include <QStringListModel>
Schedule_edit::Schedule_edit(QWidget *parent)
: QWidget(parent), ui(new Ui::Schedule_edit)
{
ui->setupUi(this);
ui->tableWidget->setColumnWidth(1, 150);
QStringList list;
model = new QStringListModel();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("/Users/andreymityulin/Desktop/S2.sqlite");
QSqlQuery query;
if (db.isOpen())
{
query.exec("SELECT OVERALL FROM LESSONS_NAMES_5_9");
QSqlRecord rec = query.record();
while (query.next())
{
list << query.value(rec.indexOf("OVERALL")).toString();
}
model->setStringList(list);
ui->listView->setModel(model);
db.close();
}
}
but I have no ideas why no data is received. I ensure the path to DB is typed correctly. Please, help me correct the code!
Aucun commentaire:
Enregistrer un commentaire