I have a problem with Signal/Slot connections when a slot exists in a derived class, but not the baseclass. Imagine the following code, where class A is derived from QObject, and class B is derived from class A.

Class A:
Qt Code:
  1. #include <QObject>
  2.  
  3. class A : public QObject
  4. {
  5. Q_OBJECT
  6.  
  7. public:
  8. A(QObject *parent = NULL);
  9. virtual ~A() {};
  10. };
  11.  
  12. A::A(QObject *parent) : QObject(parent)
  13. {
  14. }
To copy to clipboard, switch view to plain text mode 

Class B:
Qt Code:
  1. #include "A.h"
  2.  
  3. class B : public A
  4. {
  5. public:
  6. B(QObject *parent = NULL);
  7. virtual ~B() {};
  8.  
  9. public slots:
  10. void mySlot();
  11. };
  12.  
  13. B::B(QObject *parent) : A(parent)
  14. {
  15. }
  16.  
  17. void B::mySlot()
  18. {
  19. qDebug("B::mySlot called");
  20. }
To copy to clipboard, switch view to plain text mode 

Now I want to create an instance of class B, and connect the slot defined in class B (but not in class A!) to a signal.

Qt Code:
  1. QApplication app(argc, argv);
  2. B b;
  3. QObject::connect(&app, SIGNAL(aboutToQuit()), &b, SLOT(mySlot()));
To copy to clipboard, switch view to plain text mode 

Instead of the slot being called, I get the following warning in the debug output:
Qt Code:
  1. WARNING: Object::connect: No such slot A::mySlot()
  2. WARNING: Object::connect: (sender name: 'tst_Qt')
To copy to clipboard, switch view to plain text mode 

Why does it try to connect to A::mySlot()? b is clearly an instance of B, not of A.
Qt is version 4.3.1. I'd be very happy about any hint to solve this problem..