How to define signals in interfaces?
class ISomeInterface
{
signals:
virtual void added(const QString& id) = 0;
virtual void removed(const QString& id) = 0;
// bla, other methods
}
Afaik, signals should not virtual but if I want to define that a signal needs to be implemented in classes implementing the interface => how to do this? Or do you simply make them non-abstract... but interfaces have no Q_OBJECT declaration here! Is the correct code generated in this cases? On top... you'll need a bad (f***g) cast to QObject if you want to connect to the signals.
class ISomeInterface
{
signals:
void added(const QString& id);
void removed(const QString& id);
// bla, other methods
}
Or do you try to implement it that way?
class ISomeInterface : public QObject
{
Q_OBJECT
signals:
void added(const QString& id);
void removed(const QString& id);
// bla, other methods
}
Q_DECLARE_INTERFACE(ISomeInterface, "ISomeInterface")
.. but this way I can inherit from only one interface (QObject does not support multiple inheritance).
Conclusion: As suggested, I would go with the first one.