Loading...
Searching...
No Matches
SBGSettings Class Reference

This class is used to save and load settings. More...

Loading and saving values

SBGSettingsData * dataPointer
 
void saveValue (const QString &name, QVariant value)
 Saves a value.
 
QVariant loadValue (const QString &name, QVariant defaultValue=0)
 Loads a value.
 
bool loadBoolValue (const QString &name, bool defaultValue=0)
 Loads a boolean.
 
int loadIntValue (const QString &name, int defaultValue=0)
 Loads an integer.
 
qreal loadDoubleValue (const QString &name, double defaultValue=0)
 Loads a double.
 
QString loadQStringValue (const QString &name, const QString &defaultValue=0)
 Loads a string.
 

Constructor and destructor

 SBGSettings (const QString &widgetID, const QString &setting)
 
 ~SBGSettings ()
 

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;
This class is used to save and load settings.
Definition: SBGSettings.hpp:17
void saveValue(const QString &name, QVariant value)
Saves a value.
Definition: SBGSettings.cpp:58

Constructor & Destructor Documentation

◆ SBGSettings()

SBGSettings::SBGSettings ( const QString &  widgetID,
const QString &  setting 
)
Parameters
widgetID(const QString &) param containing the ID of the widget
setting(const QString &) param containing the name of the setting we want to save

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;
QString loadQStringValue(const QString &name, const QString &defaultValue=0)
Loads a string.
Definition: SBGSettings.cpp:98
bool loadBoolValue(const QString &name, bool defaultValue=0)
Loads a boolean.
Definition: SBGSettings.cpp:74

Note: when typing QSettings settings("company", "program"); will be stored in a location that depends on the OS

Unix : $HOME/.config/company/program.conf , $HOME is your HOME directory

Mac OS X : $HOME/Library/Preferences/com.company.program.plist , $HOME is your HOME directory

Windows : HKEY_CURRENT_USER\Software\company\program

Member Function Documentation

◆ loadBoolValue()

bool SBGSettings::loadBoolValue ( const QString &  name,
bool  defaultValue = 0 
)

Return the saved bool corresponding to the name, if there is no bool saved corresponding to the name, returns defaultValue or 0;.

◆ loadDoubleValue()

double SBGSettings::loadDoubleValue ( const QString &  name,
double  defaultValue = 0 
)

Return the saved double corresponding to the name, if there is no double saved corresponding to the name, returns defaultValue or 0;.

◆ loadIntValue()

int SBGSettings::loadIntValue ( const QString &  name,
int  defaultValue = 0 
)

Return the saved int corresponding to the name, if there is no int saved corresponding to the name, returns defaultValue or 0;.

◆ loadQStringValue()

QString SBGSettings::loadQStringValue ( const QString &  name,
const QString &  defaultValue = 0 
)

Return the saved QString corresponding to the name, if there is no QString saved corresponding to the name, returns defaultValue or 0;.

◆ loadValue()

QVariant SBGSettings::loadValue ( const QString &  name,
QVariant  defaultValue = 0 
)

Return the saved QVariant corresponding to the name, if there is no QVariant saved corresponding to the name, returns defaultValue or 0;.

◆ saveValue()

void SBGSettings::saveValue ( const QString &  name,
QVariant  value 
)

Save the QVariant value on the variable name On the folder KEY_COMPANY_NAME/SAMSON/currentWidgetID/userSettings/currentSetting/currentCategory/name