Как в классе, производном от QObject, можно определить класс таким образом, чтобы он также наследовался от QObject? ⇐ C++
Как в классе, производном от QObject, можно определить класс таким образом, чтобы он также наследовался от QObject?
In class A, I define a class B. I want to hide the implementation of class B. The class B inheirts from QObject. The code like follows:
// a.h class A : public QObject { Q_OBJECT public: explicit A(QObjcet* parent=nullptr); private: class B; QSharedPointer m_impl; }; //a.cpp class A::B : public QObject { Q_OBJECT public: ... }; A::A(QObject* parent) : QObject(parent), m_impl(QSharedPointer(new B())) { } But it has errors:
undefined reference to 'vtable for A::B' undefined reference to 'A::B::staticMetaObject' How can I fix it and why? Thanks!
Источник: https://stackoverflow.com/questions/780 ... hat-it-inh
In class A, I define a class B. I want to hide the implementation of class B. The class B inheirts from QObject. The code like follows:
// a.h class A : public QObject { Q_OBJECT public: explicit A(QObjcet* parent=nullptr); private: class B; QSharedPointer m_impl; }; //a.cpp class A::B : public QObject { Q_OBJECT public: ... }; A::A(QObject* parent) : QObject(parent), m_impl(QSharedPointer(new B())) { } But it has errors:
undefined reference to 'vtable for A::B' undefined reference to 'A::B::staticMetaObject' How can I fix it and why? Thanks!
Источник: https://stackoverflow.com/questions/780 ... hat-it-inh
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение