I’m writing a small app in qt that is to access some data in an sqlite database and stick it in a table. I’m completely new to qt and darn rusty with c++ so brace yourselves for a potentially stupid question…
So I have a QTableView and a database. I found a lovely little example at http://doc.trolltech.com/4.3/qsqlquerymodel.html#details that I will reproduce here for convenience:
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("SELECT name, salary FROM employee");
model->setHeaderData(0, Qt::Horizontal, tr("Name"));
model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
QTableView *view = new QTableView;
view->setModel(model);
view->show();
Looks nice and simple. But alas! It turns out that the qt installer i used (for 32 bit windows) seems to not include the necessary libraries. So I started looking for them. Once I had the QSqlQueryModel class down I found that it had a load of dependencies too. So I hit the gitorious repo where everything is stored and subsequently found out that if I want to use the sqlite stuff I need to run ‘configure’ in order to enable the database driver i’m interested in before building the source.
I wondered around my qt installation directory a bit and there are some sql related dlls, I dont know what’s in them though.
So the question is, how do I get sqlite and qt talking nicely if i want to use qtCreator?
It’s been a while since I’ve done a Windows build but as far as I know it should prebuild the SQLite files, but I have a feeling it only does the SQLite2 ones.
If you’ve tried the Qt instructions on building the driver and it’s still being a pain just make sure you’ve got the sqlite libraries, head into the applications folder and look for plugins/sqldrivers and there’ll be a .pro file in there to compile the drivers, you should be able to build that from the command line.