我正在尝试为treeView设置模型,(我的模型类继承自QAbstractItemModel)
CardsTreeModel * myModel=new CardsTreeModel(file.readAll());
QObject * pTree = m_pQmlObject->findChild<QObject*>("cardsTreeView");
pTree->setProperty("model", myModel );
并且出现了这样的错误:
qvariant.h:465: error: 'QVariant::QVariant(void*)' is private
inline QVariant(void *) Q_DECL_EQ_DELETE;
cardchoice.cpp:27: error: within this context
pTree->setProperty("model", myModel );
^
请帮我解决这个问题!
答案 0 :(得分:1)
你的myModel QObject?我在C ++中使用类时遇到同样的问题,记得添加Q_OBJECT和qmake。