当前位置:   article > 正文

使用QTreeView和QListView来显示当前目录的内容_qtreeview显示文件列表

qtreeview显示文件列表
  1. #include <QApplication>
  2. #include <QFileSystemModel>
  3. #include <QTreeView>
  4. #include <QListView>
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication a(argc, argv);
  8. QFileSystemModel model;//创建文件系统模型
  9. model.setRootPath(QDir::currentPath());//指定要监视的目录
  10. QTreeView tree;//创建树型视图
  11. tree.setModel(&model);//为视图指定模型
  12. tree.setRootIndex(model.index(QDir::currentPath()));//指定根索引
  13. tree.show();
  14. QListView list;
  15. list.setModel(&model);
  16. list.setRootIndex(model.index(QDir::currentPath()));
  17. list.show();
  18. return a.exec();
  19. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/764719
推荐阅读
相关标签
  

闽ICP备14008679号