access a signal of base class within the derived class
-
Hi,
I want to capture a signal from my base class in the derived class// base class
class Client_Base : public QObject { Q_OBJECT Q_PROPERTY(bool connected READ connected WRITE setConnected NOTIFY connectedChanged) public: void setConnected(bool co){ // ... emit connectedChanged(); } }
i need to connect a function to the connectedChanged signal
// derived class ctor
Client_Setup::Client_Setup(QObject *parent){ QObject::connect(this, &Client_Setup::connectedChanged,[&]{ // ... }); }
but this way the code in the lambda is not executed, i have to use the base class name like :
QObject::connect(this, &Client_Base::connectedChanged,[&]{}
Is this normal ?
Why do i have to write the base class name to access the signal ?Thx
-
Maybe the function address is different? It shouldn't be the case I think but am not sure.
You do have
Q_OBJECT
macro in your subclass? And you do initialize parent in constructor withClient_Setup::Client_Setup(QObject *parent) : Client_Base(parent)
? -
@sierdzio said in access a signal of base class within the derived class:
Maybe the function address is different?
e.g. by re-defining the signal in the derived class. We need to see the complete code and best a minimal, compilable example.
-
hi thx for answers
@Christian-Ehrlicher said in access a signal of base class within the derived class:
by re-defining the signal in the derived class
yes, I accidentally redefined a signal with the same name in the derived class, that was the issue.