[Qt-interest] QSqlDatabase: load sqlite base from users home directory
Bob Hood
bhood2 at comcast.net
Sun Oct 30 16:38:56 CET 2011
On 10/30/2011 9:13 AM, Nicholas Shatokhin wrote:
> Hello.
>
> How can I tell QSqlDatabase to load database not from app directory. How
> can I set directory path?
Hi, Nick.
I may be wrong, but I've always assumed that the call to setDatabaseName()
takes a file-system path to the sqlite database file, something like (untested):
QString db_name = QString("%1%2db1.sqlite")
.arg(QDir::homePath())
.arg(QDir::separator());
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "db1");
db.setDatabaseName(QDir::toNativeSeparators(db_name));
if(!db.open())
return false;
Render me gone, |||
Bob ^(===)^
---------------------------------oOO--(_)--OOo---------------------------------
"One of the penalties for refusing to participate in politics is that you
end up being governed by your inferiors." -- /Plato/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111030/366ed6c9/attachment.html
More information about the Qt-interest-old
mailing list