[SailfishDevel] sqlite absolute path

Krisztian Olah fasza2mobile at gmail.com
Thu Aug 7 21:06:24 UTC 2014


Hi again,
  I fixed the issue with applicationName() and also figured out why
setApplicationName() didn't work for me. Basically I had a global Database
object that got initalized before main() was called, therefore setting
applicationName in main would have no effect in Database. Database is now
an object created on the heap to which all objects that need to use it get
a pointer.
  QStandardPaths::writableLocation(QStandardPaths::DataLocation) now
correctly returns "/home/nemo/.local/share/harbour-myapp/" however, setting
it as a path does not work for me /harbour-myapp directory doesn't get
created and my database doesn't get saved.
Saving my data to /home/nemo/.local/share/ still works if I set the path
manually, I just cannot save the data in my corresponding subdirectory with
QStandardPaths::writableLocation(QStandardPaths::DataLocation)

Help would be greatly appricated
Kris


On 6 August 2014 14:20, Krisztian Olah <fasza2mobile at gmail.com> wrote:

> Hi,
> I just noticed that application name is not set and
> QCoreApplication::applicationName() returns empty string. Neither
> QCoreApplication::setApplicationName(arg) nor
> QGuiApplication::setApplicationName(arg) seem to make a difference.
> My db file is currently just dumped to /home/nemo/.local/share appending
> with "/harbour-myapp/" is not possible, I guess that
> QCoreApplication::applicationName needs to be set in order to get the
> proper path.
>
> Internet search came up only with one relevant page that just turned into
> a rant, but gave me little to no insight.
>
> How do I set applicationName?
> https://lists.sailfishos.org/pipermail/devel/2014-February/003258.html
> seems to imly that it should happen automatically, so does Qt's
> documentation here:
> http://qt-project.org/doc/qt-5/qcoreapplication.html#applicationName-prop
>
> Thanks in advance
> Kris
>
>
> On 4 August 2014 00:01, <fasza2mobile at gmail.com> wrote:
>
>> Thanks again, works like a charm.
>>
>> On Sun Aug 03 2014 14:06:32 GMT+0100 (BST), Lukas Vogel wrote:
>> > You shouldn't write in /usr/* directory. Rather use standard path:
>> > See
>> https://lists.sailfishos.org/pipermail/devel/2014-February/003258.html
>> >
>> >
>> > See also:
>> > http://comments.gmane.org/gmane.comp.handhelds.sailfishos.devel/3632
>> >
>> >
>> >
>> > 2014-08-03 15:00 GMT+02:00 Krisztian Olah <fasza2mobile at gmail.com>:
>> >
>> > > Hi I need a bit of help with saving my database. When I do:
>> > >
>> > > QSqlDatabase db;
>> > > db.setDatabaseName("/usr/share/<harbour-myapp>/data/data.sqlite")
>> > > db.open()
>> > > ...
>> > >
>> > > I get this error: "QSqlQuery::exec: database not open"
>> > > thus the file isn't created at all.
>> > > However if I change name to "data.sqlite" it works fine, but saves it
>> to
>> > > /home/nemo/
>> > > Could someone tell me what I need to do in order to save the file
>> under
>> > > the correct path?
>> > >
>> > > Thanks in advance
>> > > Kris
>> > >
>> > > _______________________________________________
>> > > SailfishOS.org Devel mailing list
>> > > To unsubscribe, please send a mail to
>> > > devel-unsubscribe at lists.sailfishos.org
>> > >
>> >
>>
>> --
>> Sent from my Jolla
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140807/9a39d20f/attachment.html>


More information about the Devel mailing list