0

I have a question - how to connect base class signal to inherited class slot. I`ve got a code like this

class A: public QObject
{
    Q_OBJECT
public:
    A(){}
    void EmitSignal()
    {
    emit(Asignal());
    }
signals:
    void Asignal(); 
};

class B: public A
{
public:
    B();
public slots:
    void Bslot()
        {
        //dosmth
        }
};

B::B()
{
    connect(this, SIGNAL(Asignal()), this, SLOT(Bslot()));
}

int main(int argc, char *argv[]) 
{
    B Bobject;
    B.EmitSignal();
}

and when I call B.EmitSignal() I suppose to have Bslot() called, but I got a message in output window

QObject::connect: No such slot A::Bslot().

How can I achieve Bslot() execution?

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

Found the solution. I forgot Q_OBJECT macro in inherited class