QSettings settings("mycompany", "myapp"); QString myString = settings.readEntry("myString", "default value");
QSettings settings("mycompany", "myapp"); int myInt = settings.readEntry("myInt", 0);
struct MyStruct { int value1; QString value2; }; Q_DECLARE_METATYPE(MyStruct) QSettings settings("mycompany", "myapp"); MyStruct myStruct = settings.readEntry("myStruct", MyStruct{0, "default"});This code defines a custom struct MyStruct, registers it with the Qt metatype system using Q_DECLARE_METATYPE, and then creates a QSettings object as before. It then retrieves the "myStruct" entry, with a default value of {0, "default"} if the entry is not found. In all of these examples, the QSettings class is part of the Qt package library.