QSettingsDialog  1.0.0
A Qt library to easily create a settings dialog for user configurable settings
qsettingswidgetfactory.h
1 #ifndef QSETTINGSWIDGETFACTORY_H
2 #define QSETTINGSWIDGETFACTORY_H
3 
4 #include "qsettingsdialog_global.h"
5 #include "qsettingswidget.h"
6 
8 class QSETTINGSDIALOGSHARED_EXPORT QSettingsWidgetFactory
9 {
10 public:
12  inline virtual ~QSettingsWidgetFactory() {}
13 
15  virtual QSettingsWidgetBase *createWidget(QWidget *parent) = 0;
16 };
17 
19 template <class TSettingsWidget>
21 {
22 public:
24  return new TSettingsWidget(parent);
25  }
26 };
27 
29 #define REGISTER_TYPE_CONVERTERS(TypeA, TypeB) do {\
30  QMetaType::registerConverter<TypeA, TypeB>([](TypeA aVal) -> TypeB {\
31  return (TypeB)aVal;\
32  });\
33  QMetaType::registerConverter<TypeB, TypeA>([](TypeB bVal) -> TypeA {\
34  return TypeA(bVal);\
35  });\
36 } while(false)
37 
39 #define REGISTER_FLAG_CONVERTERS(FlagsType) REGISTER_TYPE_CONVERTERS(FlagsType, int)
40 
41 #endif // QSETTINGSWIDGETFACTORY_H
The base class for a factory to create QSettingsWidgets.
Definition: qsettingswidgetfactory.h:8
virtual ~QSettingsWidgetFactory()
Virtual destructor.
Definition: qsettingswidgetfactory.h:12
[INTERNAL USE] Generic base class for a factory to create QSettingsWidgets
Definition: qsettingswidgetfactory.h:20
The base class for edit widgets in the settings dialog.
Definition: qsettingswidget.h:11
QSettingsWidgetBase * createWidget(QWidget *parent) final
Creates a new instance of the settings widget.
Definition: qsettingswidgetfactory.h:23