[SailfishDevel] How to handle app settings?
Bob Jelica
sailfish at jelica.se
Sun Dec 29 20:53:07 UTC 2013
That’s just a warning, I have it as well, but never had problems nor time to investigate further.
//bob
On 29 Dec 2013, at 21:48, Franck Routier (perso) <alci at mecadu.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I am trying to use the QSettings wrapper, as proposed by Bob Jelica.
> Here is what I did in my main cpp:
>
> #include <sailfishapp.h>
> #include "settings.h"
>
> int main(int argc, char *argv[])
> {
> // SailfishApp::main() will display "qml/template.qml", if you
> need more
> // control over initialization, you can use:
> //
> // - SailfishApp::application(int, char *[]) to get the
> QGuiApplication *
> // - SailfishApp::createView() to get a new QQuickView * instance
> // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
> //
> // To display the view, call "show()" (will show fullscreen on
> device).
>
> Settings settings;
>
> QQuickView *view = SailfishApp::createView();
> //create the root context and set the context properties
> QQmlContext *rootContext = view->rootContext();
> //register our c++ modules for usage in QML
> rootContext->setContextProperty("settings", &settings);
>
> return SailfishApp::main(argc, argv);
> }
>
>
> Everything compiles fine, but on deployment, I get these messages:
>
> [W] QCoreApplication::applicationDirPath:1906 -
> QCoreApplication::applicationDirPath: Please instantiate the
> QApplication object first
> [F] qt_pixmap_thread_test:76 - QPixmap: Must construct a QApplication
> before a QPaintDevice
>
> applicationPath is used in settings.cpp, but I just copied it as is
> from the download link given.
>
> I must be missing some obvious step, and would appreciate any help.
>
> Regards,
> Franck
>
>
> Le 29/12/2013 10:15, Bob Jelica a écrit :
>> See my previous mail. I use that in QML all the time.
>>
>> I guess it’s up to you, as an app developer, to decide what fits
>> your app. In spirit with agile software development, I start of
>> with the easies possible solution, with as little friction as
>> possible and take it from there. The QSettings (with QML wrapper)
>> has served me well, and I could focus my time on other parts of the
>> app instead :)
>>
>> //bob
>>
>> On 29 dec 2013, at 10:08, Franck Routier (perso) <alci at mecadu.org>
>> wrote:
>>
>>> Le 28/12/2013 19:06, Artem Marchenko a écrit :
>>>
>>>> If you want something QML that works, I use this pure QML
>>>> LocalStorage approach for the last couple of years fine -
>>>> https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml
>>>
>>>
>>>>
> I found inbetween that this is the approach promoted (for now) by Ubuntu
>>> Touch as well.
>>>>
>>>> Nowadays I would have started with wrapping QSettings though
>>>> (and pull requests to Wikipedia for changing LocalStorage use
>>>> into QSettings wrapper are welcome :))
>>>>
>>> So as I understand it, QSettings might be better, but is not yet
>>> really usable from QML out of the box (needs a wrapper of some
>>> sort, some being developped by Nokia for example).
>>>
>>> But, what makes QSettings better thant LocalStorage ? Ans what
>>> makes LocalStorage better than QSettings ?
>>>
>>> here are my first bets:
>>>
>>> LocalStorage: (+) available in qml out of the box, more standard
>>> (HTML5 ??), more powerful (sql) (-) not directly human readable /
>>> editable, security concerns (all tables available to all qml apps
>>> ??)
>>>
>>> QSettings: (+) simple text files (?) (-) not directly usable from
>>> qml
>>>
>>> there must be some other points...
>>>
>>> Best regards,
>>>
>>> Franck _______________________________________________
>>> SailfishOS.org Devel mailing list
>>
>> _______________________________________________ SailfishOS.org
>> Devel mailing list
>>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.14 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQEcBAEBAgAGBQJSwIqSAAoJEGEvoAir78RoDeUH/iVIsj1VnsW7Ku/coDF+aI0o
> NrsAYTRTz02KV1uCxeDhC/L8+RObvv8j8DHDCJoQsCFdbtdMWmJilaazxeM/IXfR
> fn/3hMfm0rNBRKLnBGAifFy3Awbfv1kR3sBpTqJUltuBI/n7SU/jEcvcsJ4TSkKC
> kZRDvq3DrxPk5CKE7VR+SuZSWE69MNQD3t7TRP0yVMtYeZdf2Ayus32obb0D+Lam
> HjJd8o+qQOu12eapo7FPQPbnFW5xZuh803492MhduTsOsAqJTsBzy8d7zvadk9b8
> YmV6wGC4JhmhwXJ6zV238S5i8PoP9SD43gv2TXNStH/Ai+0PNj+xMNIWVLgg3YI=
> =nD/S
> -----END PGP SIGNATURE-----
> _______________________________________________
> SailfishOS.org Devel mailing list
More information about the Devel
mailing list