In my GUI project in Qt there are many classes of “configuration pages” that all inherit directly from QWidget .
I recently realized that all these classes have 2 public slots ( loadSettings() and saveSettings() ).
In this regard, I have two questions:
- Does it make sense to write an intermediate base abstract class (lets call it
BaseConfigurationPage ) with these two slots as virtual pure methods? (Every possible configuration page will always have these two methods, so I would say yes) - Before I start to change much in my code (if necessary): Qt supports virtual clean slots? Is there anything I should know about?
Here is a sample code that describes everything:
class BaseConfigurationPage : public QWidget { // Some constructor and other methods, irrelevant here. public slots: virtual void loadSettings() = 0; virtual void saveSettings() = 0; }; class GeneralConfigurationPage : public BaseConfigurationPage { // Some constructor and other methods, irrelevant here. public slots: void loadSettings(); void saveSettings(); };
c ++ inheritance qt signals-slots
ereOn Jun 08 2018-10-06T00: 00Z
source share