赞
踩
- #include <QApplication>
- #include <QFileSystemModel>
- #include <QTreeView>
- #include <QListView>
-
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
-
- QFileSystemModel model;//创建文件系统模型
- model.setRootPath(QDir::currentPath());//指定要监视的目录
- QTreeView tree;//创建树型视图
- tree.setModel(&model);//为视图指定模型
- tree.setRootIndex(model.index(QDir::currentPath()));//指定根索引
- tree.show();
-
- QListView list;
- list.setModel(&model);
- list.setRootIndex(model.index(QDir::currentPath()));
- list.show();
-
- return a.exec();
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。