QObject -> Parent -> Child
Данный код в конструкторе Child:
connect(anything, SIGNAL(destroyed()), this, SLOT(testSlot1()));
приводит к следуюшему сообщению:
QObject::connect: No such slot Parent::testSlot1() in ..\test\child.cpp:6
Т.е. при регистрации почему-то берётся базовый класс, а не текущий. Попытки приведения this к Child ни к чему не привели.
Parent.h:
Раскрывающийся текст
#ifndef PARENT_H
#define PARENT_H
#include <QObject>
class Parent : public QObject
{
Q_OBJECT
public:
explicit Parent(QObject *parent = 0);
};
#endif // PARENT_H
Parent.cpp:
Раскрывающийся текст
#include "parent.h"
Parent::Parent(QObject *parent) :
QObject(parent)
{
}
Child.h:
Раскрывающийся текст
#ifndef CHILD_H
#define CHILD_H
#include "parent.h"
class Child : public Parent
{
public:
Child();
public slots:
void testSlot1();
};
#endif // CHILD_H
Child.cpp:
Раскрывающийся текст
#include "child.h"
Child::Child()
{
QObject* anything = new QObject();
connect(anything, SIGNAL(destroyed()), this, SLOT(testSlot1()));
}