[Interest] QSettings: is a group present? Crash with qWarning.
Samuel Gaist
samuel.gaist at edeltech.ch
Thu Aug 23 17:21:26 CEST 2012
Hi,
Looks like your on mac, trying on mine I get this at compilation time:
warning: cannot pass objects of non-POD type 'class QBool' through '...'; call will abort at runtime
Here is the why of your crash
Hope it helps
Samuel
On 23 août 2012, at 16:51, Sensei wrote:
> Hi everyone.
>
> Here's again a question, this time on QSettings with INI files. The
> question is simple: how do I know if a group exists in my INI file?
>
> Well, I could ask for all groups with childGroups(), and use the
> contains("theGroupName") method.
>
> Except that I don't know why this crashes when used inside a qWarning.
> This is the very simple INI file:
>
>
>
> [first]
> item=2
>
> [last]
> size=1
>
>
>
>
> This is the super simple code I've written:
>
>
>
> #include <QSettings>
> #include <QStringList>
>
> int main(int argc, char *argv[])
> {
> QSettings s("/Users/sensei/Desktop/proj.txp", QSettings::IniFormat);
>
> bool x = s.childGroups().contains("first");
> qWarning("Number of groups: %d", s.childGroups().size());
> qWarning("Contains [first]: %d", x); // OK
> qWarning("Contains [first]: %d", s.childGroups().contains("first")); //
> BOOM!
>
> return 0;
> }
>
>
> and your .pro file:
>
> TEMPLATE = app
> SOURCES += main.cpp
>
>
>
>
> I don't know why this happens. Any hints? I might be missing something
> SO obvious...
>
>
> Cheers!
>
>
>
>
> PS. My environment is OSX 10.8, the qt installation is the one that I
> installed on the previous OSX version. Qt is 4.8.0 (the SDK Maintenance
> Tool says I have no updates available).
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list