Search code examples
qtqt4signals-slotsqt4.7

Qt slot and class inheritation


In the parent class , i have a slot setup in constructor:

  Class DummyParent 
{
     protected:
        QWebPage page;

     public slots:
          DummyParent() 
          {
              connect (&page , SIGNAL(...) , SLOT(replyFinir(bool));
          } 

          void replyFinir (bool ok)
          {
               // handle reply messages
          }
  };

Now i have another class derived from DummyParent:

class DummyChild
{ 
    public slots:
        void replyFinir (bool ok)
        {

        }
}

Now i have the problem , since the slot connection setup in DummyParent's constructor , so it's connecting to the old handler , not the current one.

How can i let DummyChild::page call it's own replyFinir(bool) function ?


Solution

  • Have you forgotten virtual in the base class replyfinir?

    Alternately just disconnect/reconnect the signal in the derived class ctor