
Originally Posted by
ad5xj
DB is ONLY a mainwindow public member and the createConnection() is in the Mainwindow code.
No, it's not. Look:
static bool createConnection()
{
...
}
static bool createConnection()
{
...
}
To copy to clipboard, switch view to plain text mode
createConnection() is a static function, so it's not a method of Mainwindow class, even if it ends up in the same file.
The second problem is that you do have two DB variables:
QSqlDatabase * DB = QSqlDatabase::addDatabase("QSQLITE");
To copy to clipboard, switch view to plain text mode
In this line the "QSqlDatabase * DB" part means "declare a new local variable named DB of QSqlDatabase * type". It should be:
pointerToMainwindow
->DB
= QSqlDatabase::addDatabase("QSQLITE");
pointerToMainwindow->DB = QSqlDatabase::addDatabase("QSQLITE");
To copy to clipboard, switch view to plain text mode
Although you should rather make createConnection() a method of Mainwindow class, if openDB() is already there.
But before you change your code further, make sure that Qt is configured correctly on your system. If everything is OK with your system, the sqlbrowser demo should list "QSQLITE" driver in Driver combo box in Connect dialog window.
Bookmarks