Is there a way to use a Qt5-style signal-to-slot connection if the signals are declared in the interfaces ?.
My interfaces:
class IMyInterfaces{
protected:
IMyInterfaces() {}
public:
virtual ~IMyInterfaces(){}
signals:
virtual void notify_signal() =0;
};
Q_DECLARE_INTERFACE(IMyInterfaces, "IMyInterfaces");
And the class that implements the interfaces above:
class MyClass : public QObject, public IMyInterfaces{
Q_OBJECT
Q_INTERFACES(IMyInterfaces)
public:
MyClass():QObject(){
}
~MyClass(){}
signals:
void notify_signal();
};
In the main program, I would like to do something like this:
IMyInterfaces * myObject = new MyClass();
connect(myObject ,&IMyInterfaces::notify_signal, otherObject, &OtherClass::aSlot);
The old style works, but requires dropping in a QObject:
QObject::connect(dynamic_cast<QObject *>(m),SIGNAL(notify_signal()),other,SLOT(aSlot()));
source
share