#include <QtCore/private/qobject_p.h>#include <QtGui/private/qwidget_p.h>
class QObjectData {public: virtual ~QObjectData() = 0; QObject *q_ptr; QObject *parent; QObjectList children;......};
... QObject *q_ptr;...
#ifndef MYBASECLASS_H#define MYBASECLASS_H#include <QObject>class MyBasePrivateClass;class MyBaseClass : public QObject{ Q_OBJECTpublic: MyBaseClass(QObject *parent = 0); void setParam(int val); int param() const;protected: MyBasePrivateClass * const d_ptr; //MyBaseClass(MyBasePrivateClass &dd, QObject *parent);private: Q_DECLARE_PRIVATE(MyBaseClass) Q_DISABLE_COPY(MyBaseClass)};#endif
#include "mybaseclass.h"class MyBasePrivateClass{ Q_DECLARE_PUBLIC(MyBaseClass)public: MyBasePrivateClass() { m_param = 0; } virtual ~MyBasePrivateClass() {} int m_param; MyBaseClass *q_ptr;};MyBaseClass::MyBaseClass(QObject *parent) : QObject(parent), d_ptr(new MyBasePrivateClass){ // Q_D(MyBaseClass);}void MyBaseClass::setParam(int val){ Q_D(MyBaseClass); d->m_param = val;}int MyBaseClass::param() const{ Q_D(const MyBaseClass); return d->m_param;}
C++ (Qt)# 1 "/usr/include/QtCore/QObject" 2# 5 "mybaseclass.h" 2 class MyBasePrivateClass;class MyBaseClass : public QObject{ public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0) { return staticMetaObject.tr(s, c); } static inline QString trUtf8(const char *s, const char *c = 0) { return staticMetaObject.trUtf8(s, c); } static inline QString tr(const char *s, const char *c, int n) { return staticMetaObject.tr(s, c, n); } static inline QString trUtf8(const char *s, const char *c, int n) { return staticMetaObject.trUtf8(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private:public: MyBaseClass(QObject *parent = 0); void setParam(int val); int param() const;protected: [b]MyBasePrivateClass[/b] * const d_ptr; private: inline [b]MyBaseClassPrivate[/b]* d_func() { return reinterpret_cast<MyBaseClassPrivate *>(d_ptr); } inline const MyBaseClassPrivate* d_func() const { return reinterpret_cast<const MyBaseClassPrivate *>(d_ptr); } friend class MyBaseClassPrivate; MyBaseClass(const MyBaseClass &); MyBaseClass &operator=(const MyBaseClass &);};# 2 "mybaseclass.cpp" 2
class KFooBasePrivate;class KFooBase : public QObject{public: KFooBase(QObject *parent); void setSomeInteger(int i); int someInteger() const;protected: KFooBasePrivate * const d_ptr; KFooBase(KFooBasePrivate &dd, QObject *parent);private: friend class KFooBasePrivate; inline KFooBasePrivate *d_func() { return d_ptr; } inline const KFooBasePrivate *d_func() const { return d_ptr; }};