title: Qt signals inheritance?
body: <p><strong>EDIT</strong>: I provided an answer but I'd be happy to accept another one that provides an explanation.</p>
  
  <p>I subclassed <code>QPushButton</code> to add some functionality, but after connection the <code>clicked</code> signal to a slot, it doesn't get called. If I use a vanilla QPushButton, and don't change anything else, it works. Here's the code:</p>
  
  <pre><code>/// --- imagebutton.h
  
  #ifndef IMAGEBUTTON_H
  #define IMAGEBUTTON_H
  
  #include &lt;QPushButton&gt;
  #include &lt;QImage&gt;
  
  enum ButtonState
  {
      Normal,
      MouseOver,
      Pushed
  };
  
  class ImageButton : public QPushButton
  {
      Q_OBJECT
  private:
      ButtonState state;
  
  public:
      QImage *NormalImage;
      QImage *MouseOverImage;
      QImage *PushedImage;
  
  public:
      explicit ImageButton(QWidget *parent = 0);
      virtual ~ImageButton();
      void enterEvent(QEvent *e);
      void leaveEvent(QEvent *e);
      void mousePressEvent(QMouseEvent *e);
      void mouseReleaseEvent(QMouseEvent *e);
      void paintEvent(QPaintEvent *e);
  
  signals:
  
  public slots:
  
  };
  
  #endif // IMAGEBUTTON_H
  
  /// --- imagebutton.cpp
  
  #include &lt;QPainter&gt;
  
  #include "imagebutton.h"
  
  ImageButton::ImageButton(QWidget *parent) :
      QPushButton(parent)
  {
      state = Normal;
  }
  
  void ImageButton::enterEvent(QEvent *e)
  {
      QPushButton::enterEvent(e);
      state = MouseOver;
      this-&gt;repaint();
  }
  
  void ImageButton::leaveEvent(QEvent *e)
  {
      QPushButton::leaveEvent(e);
      state = Normal;
      this-&gt;repaint();
  }
  
  void ImageButton::mousePressEvent(QMouseEvent *e)
  {
      QPushButton::mousePressEvent(e);
      state = Pushed;
      this-&gt;repaint();
  }
  
  void ImageButton::mouseReleaseEvent(QMouseEvent *e)
  {
      QPushButton::mousePressEvent(e);
      state = MouseOver;
      this-&gt;repaint();
  }
  
  void ImageButton::paintEvent(QPaintEvent *e)
  {
      QPainter painter(this);
  
      QImage *pic = NULL;
  
      switch (state)
      {
      case Normal:
          pic = NormalImage;
          break;
      case MouseOver:
          pic = MouseOverImage;
          break;
      case Pushed:
          pic = PushedImage;
          break;
      default:
          pic = NormalImage;
          break;
      }
  
      painter.drawImage(0, 0, *pic);
  }
  
  ImageButton::~ImageButton()
  {
      delete NormalImage;
      delete MouseOverImage;
      delete PushedImage;
  }
  </code></pre>
  
  <p>And this is how I connect the signal:</p>
  
  <pre><code>void MainWindow::initInterface()
  {
      ImageButton *btn_start = new ImageButton(ui-&gt;page);
      btn_start-&gt;setText("start");
      connect(btn_start, SIGNAL(clicked()), this, SLOT(btn_clicked()));
      // more buttons connected to the same slot
  }
  </code></pre>
  
  <p>What might be the problem here?</p>