Qt Utilities 6.18.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
QtUtilities::QtSettings Class Reference

#include <qtsettings.h>

Public Member Functions

 QtSettings ()
 Creates a new settings object.
 ~QtSettings ()
 Destroys the settings object.
void restore (QSettings &settings)
 Restores the settings from the specified QSettings object.
void save (QSettings &settings) const
 Saves the settings to the specified QSettings object.
void apply ()
 Applies the current configuration.
void reapplyDefaultIconTheme (bool isPaletteDark)
 Re-applies default icon theme assuming the palette is dark or not depending on isPaletteDark.
void reevaluatePaletteAndDefaultIconTheme ()
 Re-evaluates whether the palette is dark and re-applies default icon theme.
bool isPaletteDark ()
 Returns whether the palette is dark.
bool hasCustomFont () const
 Returns whether a custom font is set.
bool hasLocaleChanged () const
 Returns whether the last apply() call has changed the default locale.
 operator QtSettingsData & () const
 Returns a handle to the internal data.
OptionCategorycategory ()

Detailed Description

Definition at line 52 of file qtsettings.h.

Constructor & Destructor Documentation

◆ QtSettings()

QtUtilities::QtSettings::QtSettings ( )

Creates a new settings object.

Remarks
Settings are not restored automatically. Instead, some values (font, widget style, ...) are initialized from the current Qt configuration. These values are considered as system-default.

Definition at line 117 of file qtsettings.cpp.

◆ ~QtSettings()

QtUtilities::QtSettings::~QtSettings ( )

Destroys the settings object.

Remarks
Unlike QSettings not explicitly saved settings are not saved automatically.

Definition at line 127 of file qtsettings.cpp.

Member Function Documentation

◆ apply()

void QtUtilities::QtSettings::apply ( )

Applies the current configuration.

Remarks
QApplication/QGuiApplication must be instantiated before calling this method. Hence it makes most sense to call this directly after instantiating QApplication/QGuiApplication.

This function may be called multiple times. This supports restoring default settings (e.g. if use of a custom icon theme has been disabled again after it was enabled the default icon theme will be configured again).

Definition at line 276 of file qtsettings.cpp.

◆ category()

OptionCategory * QtUtilities::QtSettings::category ( )

◆ hasCustomFont()

bool QtUtilities::QtSettings::hasCustomFont ( ) const

Returns whether a custom font is set.

Definition at line 165 of file qtsettings.cpp.

◆ hasLocaleChanged()

bool QtUtilities::QtSettings::hasLocaleChanged ( ) const

Returns whether the last apply() call has changed the default locale.

Definition at line 462 of file qtsettings.cpp.

◆ isPaletteDark()

bool QtUtilities::QtSettings::isPaletteDark ( )

Returns whether the palette is dark.

Remarks
Changes to the palette since the last call to apply() and reevaluatePaletteAndDefaultIconTheme() are not taken into account.

Definition at line 454 of file qtsettings.cpp.

◆ operator QtSettingsData &()

QtUtilities::QtSettings::operator QtSettingsData & ( ) const

Returns a handle to the internal data.

Remarks
This is an opaque data structure. It can be used to construct option pages like QtLanguageOptionPage.

Definition at line 669 of file qtsettings.cpp.

◆ reapplyDefaultIconTheme()

void QtUtilities::QtSettings::reapplyDefaultIconTheme ( bool isPaletteDark)

Re-applies default icon theme assuming the palette is dark or not depending on isPaletteDark.

Re-assigns the appropriate default icon theme depending on the current palette. Call this function after the darkmode setting has changed without the current palette reflecting that but you want the darkmode setting take precedence over the palette (e.g. when using Qt Quick Material style under Android). If your application makes actually use of the palette and you want the palette take precedence than call reevaluatePaletteAndDefaultIconTheme() instead.

Note that QtSettings::isPaletteDark() will return isPaletteDark after calling this function (even though the current palette is not actually reflecting that).

Remarks
  • The default icon theme must have been assigned before using the apply() function.
  • This function has no effect if a custom icon theme is configured.

Definition at line 422 of file qtsettings.cpp.

◆ reevaluatePaletteAndDefaultIconTheme()

void QtUtilities::QtSettings::reevaluatePaletteAndDefaultIconTheme ( )

Re-evaluates whether the palette is dark and re-applies default icon theme.

Re-assigns the appropriate default icon theme depending on the current palette. Call this function after the palette has changed.

Remarks
  • The default icon theme must have been assigned before using the apply() function.
  • This function has no effect if a custom icon theme is configured.

Definition at line 443 of file qtsettings.cpp.

◆ restore()

void QtUtilities::QtSettings::restore ( QSettings & settings)

Restores the settings from the specified QSettings object.

Remarks
The restored values are not applied automatically (except translation path).
See also
apply(), save()

Definition at line 176 of file qtsettings.cpp.

◆ save()

void QtUtilities::QtSettings::save ( QSettings & settings) const

Saves the settings to the specified QSettings object.

Definition at line 205 of file qtsettings.cpp.


The documentation for this class was generated from the following files: