QtCanpool 3.3.0
载入中...
搜索中...
未找到
QxCore::QxSettings类 参考

Thin wrapper around QSettings that keeps call sites free of the usual boilerplate: typed accessors with defaults, group handling and a versioned migration hook for layout changes between releases. 更多...

#include <qxcore/qxsettings.h>

类 QxCore::QxSettings 继承关系图:

Public 类型

using Migration = std::function< void(QxSettings &settings)>
 A migration step that upgrades the stored layout to a target version.
 

Public 成员函数

 QxSettings (const QString &organization, const QString &application=QString(), QObject *parent=nullptr)
 Settings stored in the platform-native location for organization / application.
 
 QxSettings (const QString &fileName, QSettings::Format format, QObject *parent=nullptr)
 Settings stored in an explicit file, which keeps tests hermetic.
 
 ~QxSettings () override
 
QSettings * settings () const
 The underlying QSettings instance, never null.
 
QString fileName () const
 Backing file name, empty for platform-native storage.
 
void beginGroup (const QString &prefix)
 
void endGroup ()
 
QString group () const
 
bool contains (const QString &key) const
 
QVariant value (const QString &key, const QVariant &defaultValue=QVariant()) const
 
QString stringValue (const QString &key, const QString &defaultValue=QString()) const
 
int intValue (const QString &key, int defaultValue=0) const
 
bool boolValue (const QString &key, bool defaultValue=false) const
 
QStringList stringListValue (const QString &key, const QStringList &defaultValue=QStringList()) const
 
QStringList allKeys () const
 
void setValue (const QString &key, const QVariant &value)
 
void remove (const QString &key)
 
void clear ()
 
void sync ()
 
void setVersionKey (const QString &key)
 Key holding the layout version; "version" by default.
 
QString versionKey () const
 
int version () const
 
void setVersion (int version)
 
void addMigration (int version, Migration migration)
 Registers a migration that upgrades the layout to version.
 
int migrate (int targetVersion)
 Applies every registered step whose version is greater than the stored version and not greater than targetVersion, then stores targetVersion.
 
void valueChanged (const QString &key, const QVariant &value)
 Emitted whenever a value is written or removed.
 

详细描述

Thin wrapper around QSettings that keeps call sites free of the usual boilerplate: typed accessors with defaults, group handling and a versioned migration hook for layout changes between releases.

A QxSettings object owns its QSettings instance, so an application can keep one instance instead of constructing QSettings everywhere; when a migration step runs it always goes through the same object the application reads from.

在文件 qxsettings.h 第 31 行定义.

成员类型定义说明

◆ Migration

using QxCore::QxSettings::Migration = std::function<void(QxSettings &settings)>

A migration step that upgrades the stored layout to a target version.

在文件 qxsettings.h 第 36 行定义.

构造及析构函数说明

◆ QxSettings() [1/2]

QxCore::QxSettings::QxSettings ( const QString &  organization,
const QString &  application = QString(),
QObject *  parent = nullptr 
)
explicit

Settings stored in the platform-native location for organization / application.

在文件 qxsettings.cpp 第 34 行定义.

◆ QxSettings() [2/2]

QxCore::QxSettings::QxSettings ( const QString &  fileName,
QSettings::Format  format,
QObject *  parent = nullptr 
)
explicit

Settings stored in an explicit file, which keeps tests hermetic.

在文件 qxsettings.cpp 第 42 行定义.

◆ ~QxSettings()

QxCore::QxSettings::~QxSettings ( )
override

在文件 qxsettings.cpp 第 50 行定义.

成员函数说明

◆ addMigration()

void QxCore::QxSettings::addMigration ( int  version,
Migration  migration 
)

Registers a migration that upgrades the layout to version.

Steps run in ascending version order, so a jump across several versions applies every step in between.

在文件 qxsettings.cpp 第 183 行定义.

◆ allKeys()

QStringList QxCore::QxSettings::allKeys ( ) const

在文件 qxsettings.cpp 第 121 行定义.

◆ beginGroup()

void QxCore::QxSettings::beginGroup ( const QString &  prefix)

在文件 qxsettings.cpp 第 69 行定义.

◆ boolValue()

bool QxCore::QxSettings::boolValue ( const QString &  key,
bool  defaultValue = false 
) const

在文件 qxsettings.cpp 第 111 行定义.

◆ clear()

void QxCore::QxSettings::clear ( )

在文件 qxsettings.cpp 第 144 行定义.

◆ contains()

bool QxCore::QxSettings::contains ( const QString &  key) const

在文件 qxsettings.cpp 第 89 行定义.

◆ endGroup()

void QxCore::QxSettings::endGroup ( )

在文件 qxsettings.cpp 第 75 行定义.

◆ fileName()

QString QxCore::QxSettings::fileName ( ) const

Backing file name, empty for platform-native storage.

在文件 qxsettings.cpp 第 61 行定义.

◆ group()

QString QxCore::QxSettings::group ( ) const

在文件 qxsettings.cpp 第 81 行定义.

◆ intValue()

int QxCore::QxSettings::intValue ( const QString &  key,
int  defaultValue = 0 
) const

在文件 qxsettings.cpp 第 106 行定义.

◆ migrate()

int QxCore::QxSettings::migrate ( int  targetVersion)

Applies every registered step whose version is greater than the stored version and not greater than targetVersion, then stores targetVersion.

Returns the number of steps that ran, or 0 when the stored version is already at targetVersion or beyond.

在文件 qxsettings.cpp 第 189 行定义.

◆ remove()

void QxCore::QxSettings::remove ( const QString &  key)

在文件 qxsettings.cpp 第 136 行定义.

◆ settings()

QSettings * QxCore::QxSettings::settings ( ) const

The underlying QSettings instance, never null.

在文件 qxsettings.cpp 第 55 行定义.

◆ setValue()

void QxCore::QxSettings::setValue ( const QString &  key,
const QVariant &  value 
)

在文件 qxsettings.cpp 第 129 行定义.

◆ setVersion()

void QxCore::QxSettings::setVersion ( int  version)

在文件 qxsettings.cpp 第 177 行定义.

◆ setVersionKey()

void QxCore::QxSettings::setVersionKey ( const QString &  key)

Key holding the layout version; "version" by default.

在文件 qxsettings.cpp 第 159 行定义.

◆ stringListValue()

QStringList QxCore::QxSettings::stringListValue ( const QString &  key,
const QStringList &  defaultValue = QStringList() 
) const

在文件 qxsettings.cpp 第 116 行定义.

◆ stringValue()

QString QxCore::QxSettings::stringValue ( const QString &  key,
const QString &  defaultValue = QString() 
) const

在文件 qxsettings.cpp 第 101 行定义.

◆ sync()

void QxCore::QxSettings::sync ( )

在文件 qxsettings.cpp 第 151 行定义.

◆ value()

QVariant QxCore::QxSettings::value ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

在文件 qxsettings.cpp 第 95 行定义.

◆ valueChanged()

void QxCore::QxSettings::valueChanged ( const QString &  key,
const QVariant &  value 
)

Emitted whenever a value is written or removed.

key is the group-qualified key, the same one the next read would use.

◆ version()

int QxCore::QxSettings::version ( ) const

在文件 qxsettings.cpp 第 171 行定义.

◆ versionKey()

QString QxCore::QxSettings::versionKey ( ) const

在文件 qxsettings.cpp 第 165 行定义.


该类的文档由以下文件生成: