Hi,

with a enum class you'll need to give the type explicitly, as there is no 
auto-conversion to int:

     settings.setValue("report.stacking", 
QVariant::fromValue<ReportStacking>(report_stacking));

The same with QVariant::value: var.value<ReportStacking>();

- Michael.

-----Original Message-----
From: Interest [mailto:interest-bounces+sue=sf.mpg...@qt-project.org] On Behalf 
Of Bob Hood
Sent: Monday, December 5, 2016 4:16 AM
To: interest@qt-project.org
Subject: [Interest] C++11 enum class and QSettings

I'm trying to save a C++11 enum class value in a QSettings.  In a header I have:

     #include <QMetaType>

     enum class ReportStacking
     {
         Stacked,
         Intermixed
     };
     Q_DECLARE_METATYPE(ReportStacking)

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to