<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qt5 QSettings works wrong ?]]></title><description><![CDATA[<p dir="auto">Hi</p>
<p dir="auto">As I was trying to load some settings from ini file into my application tests (no QApplication object is present)<br />
I spotted possible error.</p>
<p dir="auto">@ QSettings settings(fileName, QSettings::IniFormat);<br />
settings.beginGroup("group");<br />
_key1 = settings.value("key1").toString();<br />
_key2 = settings.value("key2").toString();<br />
settings.endGroup();@</p>
<p dir="auto">Code above resulted in all variables being empty. So I tweaked code a little to check whether file is missing or invalid.</p>
<p dir="auto">@ QSettings settings(fileName, QSettings::IniFormat);<br />
settings.allKeys();<br />
settings.beginGroup("group");<br />
_key1 = settings.value("key1").toString();<br />
_key2 = settings.value("key2").toString();<br />
settings.endGroup();@</p>
<p dir="auto">After adding call to allKeys all variables was loaded properly (sync does not worked).<br />
This workaround looks creepy. For me the most intuitive way to process ini file is to do it in constructor.<br />
My question is whether this is some undocumented feature or simple bug?</p>
]]></description><link>https://forum.qt.io/topic/27076/qt5-qsettings-works-wrong</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 16:18:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/27076.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 May 2013 18:18:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt5 QSettings works wrong ? on Thu, 09 May 2013 23:49:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">to use correctly Qt you MUST use QCoreApplication or one of inherited.<br />
QSettings uses it to access to standard PATH and so on.</p>
<p dir="auto">bq. void QSettings::sync()<br />
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in the meantime by another application.<br />
This function is called automatically from QSettings's destructor and by the event loop at regular intervals, so you normally don't need to call it yourself.</p>
<p dir="auto">If you don't have a Q*Application you don't have eventLoop.</p>
]]></description><link>https://forum.qt.io/post/178699</link><guid isPermaLink="true">https://forum.qt.io/post/178699</guid><dc:creator><![CDATA[mcosta]]></dc:creator><pubDate>Thu, 09 May 2013 23:49:47 GMT</pubDate></item></channel></rss>