Hi,
I was wondering if it's even possible to do the following somehow. I'm trying
to make an Interface with signals without inheriting the QObject and I have a
hard time make this compile properly:
class IMyInterface
{
public:
explicit IMyInterface();
virtual ~IMyInterface();
bool val() const;
void setVal(const bool v);
signals:
virtual void valChanged() = 0;
protected:
bool m_val;
};
Q_DECLARE_INTERFACE(IMyInterface, "IMyInterface")
class MyClass : public QObject, public IMyInterface
{
Q_OBJECT
Q_PROPERTY(bool val READ val WRITE setVal NOTIFY valChanged)
Q_INTERFACES(IMyInterface)
public:
...
signals:
virtual void valChanged() override;
};
Q_DECLARE_METATYPE(MyClass*)
The example is simplified to show my problem, the different class will inherit
different QObject type so I cannot inherit 2 different QObject type. It does
compile but this fail at link with the moc:
moc_MyClass.obj:moc_MyClass.cpp:vtable for MyClass: error: undefined reference
to 'MyClass::dirtyChanged()'
moc_MyClass.obj:moc_MyClass.cpp:vtable for MyClass: error: undefined reference
to 'non-virtual thunk to MyClass::valChanged()'
module_demo.obj:module_demo.cpp:vtable for QQmlPrivate::QQmlElement<MyClass>:
error: undefined reference to 'MyClass::valChanged()'
module_demo.obj:module_demo.cpp:vtable for QQmlPrivate::QQmlElement<MyClass>:
error: undefined reference to 'non-virtual thunk to MyClass::valChanged()'
Is there a way to use the signals/slots into an interface to be declared? That
would greatly help me do reusable code part.
[36E56279]
une compagnie [cid:[email protected]]
RAPPROCHEZ LA DISTANCE
Jérôme Godbout
Développeur Logiciel Sénior /
Senior Software Developer
p: +1 (418) 800-1073 ext.:109
amotus.ca<http://www.amotus-solutions.com/>
statum-iot.com<http://statum-iot.com/>
[cid:[email protected]]<https://www.facebook.com/LesSolutionsAmotus/>
[cid:[email protected]]
<https://www.linkedin.com/company/amotus-solutions/>
[cid:[email protected]] <https://twitter.com/AmotusSolutions>
[cid:[email protected]]
<https://www.youtube.com/channel/UCoYpQgsmj1iJZyDjTQ3x8Ig>
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest