Firstly, try to avoid C-style casts. For example, replace the following line:
checkState = (Qt::CheckState)setting.value("checkState", Qt::Unchecked).toUInt();
with this:
checkState = static_cast<Qt::CheckState>(setting.value("checkState", Qt::Unchecked).toUint());
The line where you cast checkState
to a uint
should also be changed.
Secondly, QSettings relies on QVariant for setting and retrieving values. QVariant can usually be expanded to support additional types using the Q_DECLARE_METATYPE macro. Here's the documentation:
http://doc.trolltech.com/4.6/qmetatype.html#Q_DECLARE_METATYPE
However, this mechanism does not appear to work properly with enumerations (when you call the value()
member function on QVariant). So what you have right now (minus the C-style casting) is fine.