
Originally Posted by
munna
what is databaseFile->filePath()?
Isn't enough to know that the connect() function return a true value ?
Anyway here's the code you asked:
in CDatabase.h:
private:
private:
QFileInfo *databaseFile;
To copy to clipboard, switch view to plain text mode
in CDatabase.cpp:
// constructor
CDatabase
::CDatabase(QString dbName
){
CDatabase::dbName = databaseFile->fileName();
}
// constructor
CDatabase::CDatabase(QString dbName)
{
databaseFile = new QFileInfo(dbName);
CDatabase::dbName = databaseFile->fileName();
}
To copy to clipboard, switch view to plain text mode
in SomeFile.cpp:
static CDatabase *CDB;
...
// instantiation of CDB where stest is the return of a QFileDialog::getExistingDirectory (and is not a null string)
CDB = new CDatabase(stest + "/" + dbNameStr + ".db");
static CDatabase *CDB;
...
// instantiation of CDB where stest is the return of a QFileDialog::getExistingDirectory (and is not a null string)
CDB = new CDatabase(stest + "/" + dbNameStr + ".db");
To copy to clipboard, switch view to plain text mode

Originally Posted by
munna
QSqlQuery query = new QSqlQuery(db);//This line should give error
To copy to clipboard, switch view to plain text mode
Just see in the public functions in QSqlQuery :
QSqlQuery ( QSqlDatabase db )
Like I said, the compilation is nice ;-). I don't understand why there might be an error...
I use : Qt 4.1, Windows (mingw) and Code::Blocks...
Bookmarks