Is there any way to use Qt5 style Signal & Slot connection if the signals are declared in interfaces ?.
My Interfaces:
class IMyInterfaces{
protected:
IMyInterfaces() {} //Prohibit instantiate interfaces
public:
virtual ~IMyInterfaces(){}
signals:
virtual void notify_signal() =0;
};
Q_DECLARE_INTERFACE(IMyInterfaces, "IMyInterfaces");
And a class which implements above interfaces:
class MyClass : public QObject, public IMyInterfaces{
Q_OBJECT
Q_INTERFACES(IMyInterfaces) //Indicates interface implements
public:
MyClass():QObject(){
}
~MyClass(){}
signals:
void notify_signal();
};
In main program I would like to do something like this:
IMyInterfaces * myObject = new MyClass();
//Connect signal using Qt5 style (This will introduce compilation errors)
connect(myObject ,&IMyInterfaces::notify_signal, otherObject, &OtherClass::aSlot);
The old style works but requires to cast to QObject:
QObject::connect(dynamic_cast<QObject *>(m),SIGNAL(notify_signal()),other,SLOT(aSlot())); //This works but need to cast to QObject.