我明白为什么我得到一个C2248: 'QObject::QObject' : cannot access private member declared in class 'QObject'
. Qt 对象不可复制,如下所述:
问题是,编译器消息总是指示类的最后一行(关闭)}
:
class MyQObject : public QObject {
Q_OBJECT
....
}; <-- error line
根本原因在其他地方,即。复制类的位置(其他文件,代码中的一些不同行)。这有时很难发现! 问题:有没有办法找到错误的真正原因所在的行
备注:请注意,在您标记此重复项之前。问题是关于找到根本原因,而不是像其他问题那样如何解决它。
--- 编辑 1 ---
很好的提示 Kuba et.al。这是VS2010,在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 &)'
我想知道为什么会生成一个复制构造函数。一个想法闪过我的脑海,我正在使用启用 DBus 的 Qt 版本,这可能是原因吗?