PDA

View Full Version : Abstract signals?



TorAn
22nd February 2010, 17:13
I have a plugin that implements interface (class with abstract methods) and that's all that this plugin exposes. How to make this interface signal-aware?

class IDataConnector : public QObject
{
Q_OBJECT
public:
virtual ~IDataConnector() {};
signals:
virtual void OnUpdate(QString msg) = 0;
};
...
Q_DECLARE_INTERFACE(IDataConnector, "dataconnector/1.0")

Compiler complains about signal being virtual, but it's warning and not an error :).
Client can connect to the signal (QObject::connect returns true), but "emit OnUpdate" does not call the slot in the client.

Any suggestions?

caduel
22nd February 2010, 19:16
what is the reason you declare the signal as virtual? a signal will never do anything else but notify the connected slots...
also, you will have to take care that not both the plugin and the 'client' moc the plugin header.

TorAn
22nd February 2010, 19:31
You are right, got carried away with declaration of the interface.
All works now, thanks

Now, I did not understand your comment "you will have to take care that not both the plugin and the 'client' moc the plugin header."?
Can you elablorate?