[Qt-interest] QSqlDatabase: load sqlite base from users home directory

Nicholas Shatokhin n.shatokhin at gmail.com
Sun Oct 30 18:51:15 CET 2011


So, I made this:

QSettings cfg(QSettings::NativeFormat, QSettings::UserScope, "company",  
"application");
QString config_dir = QFileInfo(cfg.fileName()).absolutePath() + "/";

QDir dir;
if(!dir.exists(config_dir))
    dir.mkpath(config_dir);

QSqlDatabase * sql = new QSqlDatabase();
sql->addDatabase("QSQLITE");
sql->setDatabaseName(cfg.fileName());
if(!sql->open())
    qDebug() << "error";

But, I always get error. What is wrong?

Sun, 30 Oct 2011 18:41:07 +0300 було написано <norulez at me.com>:

> Use QSqlDatabase::setDatabaseName();
>
>
> Am 30.10.2011 um 16:13 schrieb Nicholas Shatokhin  
> <n.shatokhin at gmail.com>:
>
>> Hello.
>>
>> How can I tell QSqlDatabase to load database not from app directory. How
>> can I set directory path?
>>
>> Best regards,
>> Nick.
>>
>> --
>> За використання революційного клієнта електронної пошти Opera:
>> http://www.opera.com/mail/
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest


-- 
За використання революційного клієнта електронної пошти Opera:  
http://www.opera.com/mail/


More information about the Qt-interest-old mailing list