Can't connect to SQLite DB
Doing my first steps in Qt Creator and lost already:
To a basic, otherwise unchanged starting app from the Qt wizzard, I have added
sqlto the project file
@ QT += core gui sql@
and the lines below to
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/home/vaettchen/testSQL/myDB.sqlite"); bool db_ok = db.open();@
According to various sources here on the Qt WebSite and on StackOverflow (where nobody could help me), I had expected that this would do it. But I get a compiler error
@../testSQL/mainwindow.cpp:20:1: error: 'db' does not name a type@
where line 20 is the db.setDataBaseName() line.
I have tried to find out via Google what this means and what can be done about it but the comments I found were not very useful.
Using Qt Creator 2.7.0 (Qt 4.8.4) on Linux 3.5
Is libsqt4-sql and libqt4-sql-sqlite installed in your system?
Thanks SergioDanielG - I do have the modules, drivers etc installed. This is all very confusing and, for a greenhorn like me, does look very inconcsistent.
The odd thing is that depending how I start the project (from a sample project or plain wizzard) things seem to be different. I have partly solved the issue by prepending the command with void and other strange stuff that looks irregular to me.
I have adapted the relationaltablemodel to use my existing sqlite file and make progress from here. I'll happily ask more questions once I understand better what I'm going at all...
Thanks once more,