在下面一行中,我得到了一个意外的错误:
MyClass * myObject = new MyClass;
view.rootContext()->setContextProperty("myObject", myObject);有错误:
error: C2248: 'QVariant::QVariant' : cannot access private member declared in class 'QVariant'但是MyClass只是我编写的一个类,它对QVariant类没有什么特别的作用。
发布于 2016-02-15 03:13:49
问题是我忘了从QObject派生QObject。它需要派生并在其中定义Q_OBJECT宏,就像对任何QObject派生类一样。
https://stackoverflow.com/questions/35400940
复制相似问题