You should add this line in your .pro file:
QT+= sql
سؤال
I created a database. Everything seems in order to start filling it up, but every timei try to debug my project it throws this error into my face:
"error: C1083: Cannot open include file: 'QtSql': No such file or directory"
I don't understand why I get it. In every projects I do the same, and it works just perfectly.
I include:
#include <QtSql>
Then I create the Database like this:
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setPort(3306);
db.setDatabaseName("nevekdb");
db.setUserName("root");
db.setPassword("");
And then i try getting it's content this way:
ui->tableWidget->setColumnCount(4);
ui->tableWidget->setRowCount(selectQuery.size());
QStringList fl;
fejlecek << "ID" << "Name" << "Password" << "Appartment Floor";
ui->tableWidget->setHorizontalHeaderLabels(fl);
int i=0;
while (selectQuery.next())
{
ui->tableWidget->setItem(i,0,new QTableWidgetItem(selectQuery.value(0).toString()));
ui->tableWidget->setItem(i,1,new QTableWidgetItem(selectQuery.value(1).toString()));
ui->tableWidget->setItem(i,2,new QTableWidgetItem(selectQuery.value(2).toString()));
ui->tableWidget->setItem(i,3,new QTableWidgetItem(QString::number(selectQuery.value(3).toInt())));
QTableWidgetItem(selectQuery.value(3).toString()));
i++;
المحلول
You should add this line in your .pro file:
QT+= sql