我的代码如下:
class Wrapper: public QObject {
Q_OBJECT
Q_PROPERTY(PeopleListModel & list READ list)
public:
PeopleListModel & list() {
return list_;
}
private:
PeopleListModel list_;
};
PeopleListModel是QAbstractListModel的子类。
但是我收到了编译错误:
^
In file included from plugin.cpp:131:0:
plugin.moc: In member function ‘virtual int Wrapper::qt_metacall(QMetaObject::Call, int, void**)’:
plugin.moc:184:52: error: cannot declare pointer to ‘class PeopleListModel&’
case 0: *reinterpret_cast< PeopleListModel&*>(_v) = list(); break;
^
In file included from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qnamespace.h:45:0,
from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qobjectdefs.h:45,
from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qobject.h:48,
from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qplugin.h:45,
from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtQml/qqmlextensionplugin.h:45,
from ../../../../Qt5.2.0/5.2.0/gcc_64/include/QtQml/QQmlExtensionPlugin:1,
from plugin.cpp:1:
../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qabstractitemmodel.h: In member function ‘PeopleListModel& PeopleListModel::operator=(const PeopleListModel&)’:
../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qglobal.h:967:12: error: ‘QAbstractListModel& QAbstractListModel::operator=(const QAbstractListModel&)’ is private
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
^
../../../../Qt5.2.0/5.2.0/gcc_64/include/QtCore/qabstractitemmodel.h:479:5: note: in expansion of macro ‘Q_DISABLE_COPY’
Q_DISABLE_COPY(QAbstractListModel)
^
plugin.cpp:32:7: error: within this context
class PeopleListModel : public QAbstractListModel {
^
In file included from plugin.cpp:131:0:
plugin.moc: In member function ‘virtual int Wrapper::qt_metacall(QMetaObject::Call, int, void**)’:
plugin.moc:184:59: note: synthesized method ‘PeopleListModel& PeopleListModel::operator=(const PeopleListModel&)’ first required here
case 0: *reinterpret_cast< PeopleListModel&*>(_v) = list(); break;
^
make: *** [plugin.o] Error 1