<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I use a QML-enabled QSettings wrapper created by Nokia at some point.<div>Here’s the download link: <a href="https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.cpp">https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.cpp</a> and <a href="https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.h">https://dl.dropboxusercontent.com/u/10015284/qml_settings/settings.h</a></div><div>Put those into your project, then register it in your main.cpp (or PROJECTNAME.cpp) like this:</div><div><br></div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">Settings</span><span style=" color:#c0c0c0;"> </span>settings;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#008000;">//create</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">root</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">context</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">and</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">set</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">context</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">properties</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">QQmlContext</span><span style=" color:#c0c0c0;"> </span>*rootContext<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>view->rootContext();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#008000;">//register</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">our</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">c++</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">modules</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">for</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">usage</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">QML</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>rootContext->setContextProperty(<span style=" color:#008000;">"settings"</span>,<span style=" color:#c0c0c0;"> </span>&settings);<!--EndFragment--></pre><div><br></div></div><div>Now you have a ”settings” object available everywhere in your QML/JS.</div><div>Usage:</div><div>Save an object: settings.setSetting(”name”, value);</div><div>Read a saved object: settings.setting(”name”);</div><div><br></div><div>Works like a charm ;)</div><div><br></div><div>//b0bben</div><div><br></div><div><br></div><div><br></div><div>On 28 Dec 2013, at 19:06, Artem Marchenko <<a href="mailto:artem.marchenko@gmail.com">artem.marchenko@gmail.com</a>> wrote:<br><div><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi there<div><br></div><div>I believe somebody was posting to IRC a link to a QML wrapper for QSettings done as a part of some nemo project.</div><div><br></div><div>If you want something QML that works, I use this pure QML LocalStorage approach for the last couple of years fine - <a href="https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml">https://github.com/amarchen/Wikipedia/blob/master/src/qml/components/DbDictionary.qml</a></div>

<div><br></div><div>Nowadays I would have started with wrapping QSettings though (and pull requests to Wikipedia for changing LocalStorage use into QSettings wrapper are welcome :))</div><div><br></div><div>Best regards,</div>

<div>Artem.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 28, 2013 at 7:45 PM, Kimmo Lindholm <span dir="ltr"><<a href="mailto:Kimmo.Lindholm@eke.fi" target="_blank">Kimmo.Lindholm@eke.fi</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I did it like this with QSettings, it works. I don't know is it the correct way... (comments anyone?)<br>
<br>
introduce me in main()<br>
    QCoreApplication::setOrganizationDomain("diibadaaba");<br>
    QCoreApplication::setOrganizationName("diibadaaba ");<br>
    QCoreApplication::setApplicationName("badbreath");<br>
    QCoreApplication::setApplicationVersion("0.1-1");<br>
<br>
read<br>
    QSettings settings;<br>
    m_mySetting = settings.value("mySetting", "").toString();<br>
<br>
write<br>
    QSettings settings;<br>
    settings.setValue("mySetting", m_mySetting);<br>
<br>
-kimmo<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
<a href="http://SailfishOS.org">SailfishOS.org</a> Devel mailing list<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Artem Marchenko<br><a href="http://agilesoftwaredevelopment.com/" target="_blank">http://agilesoftwaredevelopment.com</a><br><a href="http://twitter.com/AgileArtem" target="_blank">http://twitter.com/AgileArtem</a>
</div>
_______________________________________________<br><a href="http://SailfishOS.org">SailfishOS.org</a> Devel mailing list</blockquote></div><br></div></div></body></html>