QSettingsDialog  1.0.0
A Qt library to easily create a settings dialog for user configurable settings
Static Public Member Functions | List of all members
VariantWidgetsRegistrator Class Reference

A static class to globally register different types of edit widgets. More...

#include <variantwidgetsregistrator.h>

Static Public Member Functions

static void registerGroupWidgets ()
 Registeres the default group widgets. More...
 
static void registerVariantWidgets ()
 Registeres the default edit widgets. More...
 
static void registerEnumFactories ()
 Registeres the enum and flag edit widget facotries. More...
 
static void registerExtendedVariantWidgets ()
 Registeres the extended edit widgets. More...
 

Detailed Description

A static class to globally register different types of edit widgets.

The static members of this class can be used to globally register different types of edit widgets. They are seperated into four groups, each represented by one of the member functions.

Attention
By default, all of them will be automatically registered when the dll is loaded. You can modify this behavior by settings an environment viriable, VARIANT_WIDGETS_AUTOLOAD.

Member Function Documentation

VariantWidgetsRegistrator::registerEnumFactories ( )
static

Registeres the enum and flag edit widget facotries.

A registry is installed that is able to automatically create edit widgets for basically any enum or flags.

Enums

The requirement for enums to be used is to register the enum with #Q_ENUM. The id of the correpsonding widget will be qMetaTypeId<MyEnum>().

The enum can be displayed as a combobox or as a list of radiobuttons. This can be done using special properties.

  • showAsRadio : bool -> Can be used to show a radiolist instead of a combox. Defaults to false
  • translated : bool -> If set (the default), the combobox will look for translations

Flags

To have flags, the flags type has to be created using #Q_DECLARE_FLAGS and have to be registered with #Q_FLAG. However, in addition to that, you will have to register converter operations to QVariant to make the flags work. Use the REGISTER_FLAG_CONVERTERS macro in your main after you created the QApplication to do so.

The flags will be displayed as a Checklist. It too provides the translation property:

  • translated : bool -> If set (the default), the combobox will look for translations

Translation format

All translations will be done by using the enums name as context and the values name as key. Simple example:

class MyClass : public QObject
{
Q_OBJECT
public:
enum MyEnum {
Value0,
Value1
};
Q_ENUM(MyEnum)
};

Will have MyEnum as context and Value0 (or Value1) as key for the translation.

Note
By default this one is enabled. If you set the environment variable, use the AUTOLOAD_ENUMS value to include this
VariantWidgetsRegistrator::registerExtendedVariantWidgets ( )
static

Registeres the extended edit widgets.

The extended widgets are widgets that I decided are somewhat important to have, but are not represented by the default widgets. The following list shows all included types with their edit widgets:

Class-Name Edit widget
FilePath QPathEdit
IntRange QSlider
HtmlText QTextEdit (with advanced context menu)

To get the id's of each of these types, use e.g. qMetaTypeId<FilePath>() as id for the QSettingsEntry displayId.

Note
By default this one is enabled. If you set the environment variable, use the AUTOLOAD_EXTENDED value to include this
VariantWidgetsRegistrator::registerGroupWidgets ( )
static

Registeres the default group widgets.

The groups widgets are for now just one - the default group widget that is a QGroupBox. It has the id 0

Note
By default this one is enabled. If you set the environment variable, use the AUTOLOAD_GROUPS value to include this
VariantWidgetsRegistrator::registerVariantWidgets ( )
static

Registeres the default edit widgets.

The default widgets are widgets for known and editable types that are registered as metatypes. The following list shows all included types with their edit widgets:

Metatype Edit widget
QMetaType::Bool QCheckBox
QMetaType::UInt QSpinBox
QMetaType::Double QDoubleSpinBox
QMetaType::QString QLineEdit
QMetaType::QByteArray QLineEdit
QMetaType::Long QSpinBox
QMetaType::LongLong QSpinBox
QMetaType::Short QSpinBox
QMetaType::Char QSpinBox
QMetaType::Ulong QSpinBox
QMetaType::ULongLong QSpinBox
QMetaType::UShort QSpinBox
QMetaType::SChar QSpinBox
QMetaType::UChar QSpinBox
QMetaType::Float QDoubleSpinBox
QMetaType::QDate QDateEdit
QMetaType::QTime QTimeEdit
QMetaType::QColor QColorEdit
QMetaType::QStringList ListEdit (custom class)
QMetaType::QUrl QLineEdit (with validator)
QMetaType::QDateTime QDateTimeEdit
QMetaType::QFont QFontComboBox
QMetaType::QKeySequence QKeySequenceEdit
QMetaType::QUuid QLineEdit (with validator)
Note
By default this one is enabled. If you set the environment variable, use the AUTOLOAD_WIDGETS value to include this

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