How to find an item in a QTreeView?

跟風遠走 提交于 2019-12-13 06:12:12

问题


I understand that QTreeWidget has methods for finding an item, but since I want to use a QFileSystemModel, then I'm limited to QTreeView. However, I'd still like to be able to return all items from a QTreeView and place them into a list.

I had thought that I could go through and grab all indexes from the QTreeView, but I'm not sure how to do that.

Maybe something like:

QList<QModelIndex &> treeList;
foreach(QModelIndex &index, ui->tv_list)
{
     treeList.append(index);
}

but I know this isn't correct. What is a good way to get the items or addresses of items into a list from a QTreeView?

来源:https://stackoverflow.com/questions/15196207/how-to-find-an-item-in-a-qtreeview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!