I have created a base class that provides a common signal for all its subclasses:
#include <QWidget>
namespace Dino {
/**
* @brief Base class for all single-value settings editors
*
* Provides a valueChanged() signal that can be used to propagate changes to
* values up to the MainWindow
*/
class TypeEditor : public QWidget
{
Q_OBJECT
public:
explicit TypeEditor(QWidget *parent = 0):QWidget(parent){}
signals:
void valueChanged();
};
} // namespace Dino
In a subclass, I want to have this signal available, but also define a more specific signal with the same name but different arguments:
#include "ui/typeeditor.h"
namespace Dino {
class BoolEditor : public TypeEditor
{
Q_OBJECT
public:
explicit BoolEditor(QWidget* parent = 0):TypeEditor(parent){}
signals:
void valueChanged(bool value);
public slots:
void setValue(bool value)
{
emit valueChanged(value);
emit valueChanged();
}
};
} // namespace Dino
The idea is that when only the base class type is known, the generalized signal can be used, which tells that there has been a change in the value. When the exact subclass type is known, another signal is available, which tells the new value.
Now, when I try to compile I get an error on the emit valueChanged()
stating that there is no function called Dino::BoolEditor::valueChanged()
.
When I rename the signal in the base class to something else it works, so this seems to be a problem of overloading the signal. I would be interested in the reason for this. Is it some design requirement that I'm not aware of that prevents me from overloading a signal in a subclass, or am I just missing something in the code?