Showing filesystem in QTreeWidget

折月煮酒 提交于 2020-07-19 07:51:10

问题


I have a simple Question. I want to show my filesystem in a QTreeWidget just like an common file explorer.

How can i achieve that? I guess searching through all files and add them manual is not the approach to chose, right?


回答1:


use QDirModel and QTreeView instead of QTreeWidget, here is a code snippet:

QDirModel *model = new QDirModel;
QTreeView *tree = new QTreeView(splitter);  
tree->setModel(model);  
tree->setRootIndex(model->index("C:\\"));  


来源:https://stackoverflow.com/questions/20995257/showing-filesystem-in-qtreewidget

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