Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I have a class as follows (the MyTreeItem class does not inherit QObject).
- class MyTreeItem
- {
- // ...
- };
- Q_DECLARE_METATYPE(MyTreeItem)
- // I'm trying to add an item to my treeview, but not sure how to construct this class with
- // QVariant which is what QVariant::setData takes ...
- bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
- // And here is how I'm trying to add an item to my tree ...
- QList<QVariant> name;
- name << new_name << "";
- const QModelIndex parent = treeModel->index(0, 0);
- MyTreeItem *newItem = new MyTreeItem(name);
- treeModel->insertRow(0, parent);
- treeModel->setData(treeModel->index(0, 0, parent), QVariant(newItem));
- /* The error I get in setData above is ...
- error: use of deleted function ‘QVariant::QVariant(void*)’ treeModel->setData(treModel->index(0, 0, parent), QVariant(newItem));
- ^
- */
Advertisement
Add Comment
Please, Sign In to add comment