Error -: 'QObject::QObject' : cannot access private member declared in class 'QObject'
c++, qt
Solution
The `QObject` class has a private copy constructor. As such you can not copy instances of classes that derive from `QObject`. See also this page on the identity vs. value discussion regarding `QObject`.
If you want to be able to copy instances of `B`, either don't inherit from `QObject` or provide some means of cloning `B` (taking care to ensure that memory is managed appropriately).
Problem
I am trying to return a class that is derived from QObject and I am getting the following error ``` Error : 'QObject::QObject' : cannot access private member declared in class 'QObject' ``` This situation resembles my scenario Header File : `B.h` ``` class B : public QObject { Q_OBJECT private: ... public: B(QObject* parent = 0); ... } ``` CPP File : `B.cpp` ``` B:B(QObject *parent) { //Empty Constructor } ``` Header File : `A.h` ``` class A { private: B myClassB; public : B ReturnClassB(); } ``` CPP File : `C.cpp` ``` B A::ReturnClassB() { return myClassB; //This is where the error occurs } ``` Any suggestions on what might be going wrong ? Is it a copy constructor issue ?