Save and read enum by QSettings
Solved
General and Desktop
-
*.h { private: enum { TEXT_CLOCK, DIGITAL_CLOCK, ANALOG_CLOCK } clock_type; } *.cpp { QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); clock_type = settings.value("ClockType"); if (clock_type == NULL) clock_type = TEXT_CLOCK; QAction *action_text = new QAction("Text", this); connect(action_text, &QAction::triggered, [=](){ clock_type = TEXT_CLOCK; settings.setValue("ClockType", clock_type); }); addAction(action_text); }
-
Is it so hard to write down what your problem is instead simply posting a code snippet?
-
@sonichy said in Save and read enum by QSettings:
clock_type = settings.value("ClockType"); if (clock_type == NULL)
If you look at the docs for QSettings::value() you will see that it returns a QVariant.
So such a check doesnt make much sense.