Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
5.11.1
-
None
-
Linux Ubuntu 18.04
Qt 5.11.1
Description
Consider the following class which holds a member of type QSettings:
#include <QSettings> class MySettingsClass { public: QSize getDefaultWindowSize() const; // other getters here ... all const void setWindowSize(); // etc. private: QSettings m_settings; }; QSize MySettingsClass::getDefaultWindowSize() const { QSize retval; QString group = "window"; m_settings.beginGroup(group); // error: beginGroup is non-const! ... }
If I only want to read a setting, I should be able to do it using a const member function. However, QSettings::beginGroup() and beginReadArray() have no const overload. I could declare the QSettings member as mutable, but that is something I'd like to avoid if possible.