QT treewideget怎么实现显示一个文件及文件夹里面的子文件夹

QT treewideget怎么实现显示一个文件及文件夹里面的子文件夹,第1张

这个可以使用QTreeview和QFileSystemModel:官方文档例子如下:

It is simple to construct a tree view displaying data from a model. In the following example, the contents of a directory are supplied by a QFileSystemModel and displayed as a tree:

QFileSystemModel *model = new QFileSystemModel

model->setRootPath(QDir::currentPath())

QTreeView *tree = new QTreeView(splitter)

tree->睁搜档setModel(model)

如果要使用QTreeWidget 就要使用QFileInfo对文件夹进行悉乱遍历,挨个添加到QTreeWidget中。有关QFileInfo请参考帮助漏毁文档:http://qt-project.org/doc/qt-4.8/qfileinfo.html

String[] s={"January", "燃雀闹February"岁型, "March", "April"皮罩, "May", "June", "July", "August", "September", "October", "November", "December"}

System.out.print("请输入数字(1-12):")

BufferedReader br=new BufferedReader(new InputStreamReader(System.in))

String str=br.readLine()

int m=Integer.parseInt(str)

if (m<=0||m>=13)

{


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/8161925.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存