[SOLVED] Inheriting virtual slots and use the new QT5 connect flavour
-
Hi!
If i create a class from a base class with virtual slots, the slots never get called with the new connect-flavour.
If i use the old connect-syntax, the slot gets called. What could be the problem?@
class BaseClass: public QObject
{
public slots:virtual void Slot1() = 0; virtual void Slot2() = 0;
};
class DerivedClass: public BaseClass
{public slots:
void Slot1(); void Slot2();
};
@Why doesn't it work with the new connect-syntax but does with the old syntax?
Thank you very much!
-
I have tried just now as well.Hope you are taking about the following new syntax It works fine.
QObject::connect(&button,&QPushButton::clicked,&dobj,&DerivedClass::vslot2);I tried on Windows.
-
It is same class as yours. I have added one more slot in base class. Dll also should not cause any issue.
@class BaseClass : public QObject
{
Q_OBJECT
public:
explicit BaseClass(QObject *parent = 0);signals:
public slots:
void vslot0();
virtual void vslot1() =0;
virtual void vslot2() =0;
};class DerivedClass : public BaseClass
{
Q_OBJECT
public:
explicit DerivedClass();signals:
public slots:
void vslot1();
void vslot2();
};@ -
I have not tried with dlls. Did you create plugin or is it plain dll ? Hope you have exported the functions in dll with extern "C" to avoid any name mangling issues.