Sqlite query returns no data?
-
qDebug result is 0
db = QSqlDatabase::addDatabase("QSQLITE", "conn"); db.setDatabaseName("qt_sqlite_test.db"); if(!db.open()) { QMessageBox::critical(NULL, QObject::tr("Collection"), QObject::tr("Connection Failed")); } QSqlQueryModel *model = new QSqlQueryModel; model->setQuery("SELECT * FROM apply",db); qDebug()<<(model->rowCount());
-
Hi and welcome to devnet,
Please enclose your code with coding tags.
Check the errors returned by your model to see what might go wrong.
Also ensure that that the file you want to open is accessible, otherwise a new empty database will be created. Since you are testing, use a complete path to your database in setDatabaseName
-
Did you check the errors ?