实现的效果图如下:
#include "mainwindow.h"
#include <QApplication>
#include <QTreeView>
#include <QFileSystemModel>
#include <QComboBox>
#include <QDir>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
// 创建文件系统模型
QFileSystemModel *model = new QFileSystemModel(&w);
// 指定要监视的目录
model->setRootPath(QDir::currentPath());
QTreeView *tree = new QTreeView(&w);
tree->setModel(model);
tree->setRootIndex(model->index(QDir::currentPath()));
QComboBox *b = new QComboBox(&w);
b->resize(400, 20);
b->setView(tree);
b->setModel(model);
b->show();
w.show();
return a.exec();
}
///////完
http://blog.csdn.net/u011915578/article/details/47783577