Class SBGSettings#
This class is used to save and load settings. More...
#include <SBGSettings.hpp>
Inherits the following classes: QSettings
Public Functions#
| Type | Name |
|---|---|
| SBGSettings (const QString & widgetID, const QString & setting) Second, an example to show how to load settings. |
|
| bool | loadBoolValue (const QString & name, bool defaultValue=0) Loads a boolean. |
| qreal | loadDoubleValue (const QString & name, double defaultValue=0) Loads a double. |
| int | loadIntValue (const QString & name, int defaultValue=0) Loads an integer. |
| QString | loadQStringValue (const QString & name, const QString & defaultValue=0) Loads a string. |
| QVariant | loadValue (const QString & name, QVariant defaultValue=0) Loads a value. |
| void | saveValue (const QString & name, QVariant value) Saves a value. |
| ~SBGSettings () Destroys the SBGSettings object and releases associated resources. |
Protected Attributes#
| Type | Name |
|---|---|
| SBGSettingsData * | dataPointer |
Detailed Description#
First, an example to show how to save settings.
SBGSettings *settings = new SBGSettings(widgetID, settingsName);
// ui.fileName is a QLineEdit
settings->saveValue("fileNameValue", ui.fileName->text());
// ui.adaptive is a QCheckBox
settings->saveValue("adaptiveValue", ui.adaptive->isChecked());
delete settings;
Public Functions Documentation#
function SBGSettings#
Second, an example to show how to load settings.
SBGSettings *settings = new SBGSettings(widgetID, settingsName);
// ui.fileName is a QLineEdit
ui.fileName->setText(settings->loadQStringValue("fileNameValue", "default"));
// ui.adaptive is a QCheckBox
ui.adaptive->setChecked(settings->loadBoolValue("adaptiveValue", false));
delete settings;
Note: when typing QSettings settings("company", "program"); will be stored in a location that depends on the OS:
- Unix:
$HOME/.config/company/program.conf, where$HOMEis your HOME directory - Mac OS X:
$HOME/Library/Preferences/com.company.program.plist, where$HOMEis your HOME directory - Windows:
HKEY_CURRENT_USER\\Software\\company\\program
Constructs a SBGSettings object for the specified widget and setting.
The settings are stored under a hierarchy that includes the widget ID and setting name.
Parameters:
widgetIDIdentifier of the widget.settingName of the setting.
function loadBoolValue#
Loads a boolean.
Returns the saved boolean for the given name, or the default value if not present.
Parameters:
nameThe name (key) of the boolean to retrieve.defaultValueThe value to return if the name does not exist.
Returns:
The stored boolean, or defaultValue if not found.
function loadDoubleValue#
Loads a double.
Returns the saved double for the given name, or the default value if not present.
Parameters:
nameThe name (key) of the double to retrieve.defaultValueThe value to return if the name does not exist.
Returns:
The stored double, or defaultValue if not found.
function loadIntValue#
Loads an integer.
Returns the saved integer for the given name, or the default value if not present.
Parameters:
nameThe name (key) of the integer to retrieve.defaultValueThe value to return if the name does not exist.
Returns:
The stored integer, or defaultValue if not found.
function loadQStringValue#
Loads a string.
Returns the saved string for the given name, or the default value if not present.
Parameters:
nameThe name (key) of the string to retrieve.defaultValueThe value to return if the name does not exist.
Returns:
The stored string, or defaultValue if not found.
function loadValue#
Loads a value.
Returns the saved QVariant for the given name, or the default value if not present.
Parameters:
nameThe name (key) of the value to retrieve.defaultValueThe value to return if the name does not exist.
Returns:
The stored QVariant, or defaultValue if not found.
function saveValue#
Saves a value.
Saves a QVariant value under the given name.
The value is stored in the settings hierarchy under the folder KEY_COMPANY_NAME/SAMSON/currentWidgetID/userSettings/currentSetting/currentCategory/name.
Parameters:
nameThe name (key) for the value.valueThe QVariant to store.
function ~SBGSettings#
Destroys the SBGSettings object and releases associated resources.