I understand why I get a C2248: 'QObject::QObject' : cannot access private member declared in class 'QObject'
. Qt objects are not copyable, as explained here:
- https://stackoverflow.com/a/3513395/356726
- No copy constructor or assignment operator
The problem is, that the compiler message always indicates the last line (closing }
) of the class:
class MyQObject : public QObject {
Q_OBJECT
....
}; <-- error line
Root cause is somewhere else, ie. where the class is copied (other file, some different line in code). This is sometimes hard to spot! Question: Is there a way to locate the line of the real reason for the error
Remark: Please note, before you mark this Duplicate. Question is about finding the root cause, not how to solve it as in the other questions.
--- Edit 1 ---
Good hint Kuba et.al. It's VS2010, compiling in Qt Creator 2.8.0
'QObject::QObject'
C:\Qt\5.1.0-32\qtbase\include\QtCore/qobject.h(115) : see declaration of 'QObject'
This diagnostic occurred in the compiler generated function 'MyQObject ::MyQObject (const MyQObject &)'
I wonder why a copy constructor is generated. One idea crossed my mind, I am using the DBus enabled version of Qt, might this be the reason?