I'm trying to set up the model for the treeView,( my model class inherits from QAbstractItemModel)
CardsTreeModel * myModel=new CardsTreeModel(file.readAll());
QObject * pTree = m_pQmlObject->findChild<QObject*>("cardsTreeView");
pTree->setProperty("model", myModel );
And got such errors:
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 );
^
Help me please to resolve this problem!
setPropertytakesQVariantas its second parameter. You are passingCardsTreeModel*, which cannot be implicitly converted toQVariant. You may be able to writeQVariant::fromValue(myModel). It's not clear what you are trying to achieve though; you seem to think that "model" is some special property name and assigning to it achieves some magical effect. - Igor TandetnikQVarianthas a constructor takingQStringList, which is what I imaginem_strListViewis. Anyway, what you likely want is something likeqobject_cast<QAbstractItemView*>(pTree)->setModel(myModel);- Igor TandetnikCardsTreeModeldoesn't report the correct data to the view. Time to break out your trusty debugger, I suppose. - Igor Tandetnik