Hi,
I am trying to fill a Treeview from a database source. I need to be able to manipulate treeview items and sync this with database. As far as i can understand , best (but not easiest) way is to use QAbstractProxyModel and implement maptoSource and mapfromSource functions. But i couldnt find a single example for doing this on a treeview.
A starting point:
{
// root
if (!sourceIndex.isValid())
//what to do here
int col = sourceIndex.column();
return createIndex(sourceIndex.row() , sourceIndex.column());
}
QModelIndex TagChannelTreeModel::mapFromSource(const QModelIndex &sourceIndex) const
{
// root
if (!sourceIndex.isValid())
return QModelIndex();
//what to do here
int col = sourceIndex.column();
return createIndex(sourceIndex.row() , sourceIndex.column());
}
To copy to clipboard, switch view to plain text mode
Here what should i do if column is other than "0"(Top level item) and i want to add this index as a child to parent(column 0 item) ? A small snippet would be appreciated :-)
Thanks in advance...
Bookmarks