-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
37 lines (28 loc) · 977 Bytes
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "mainwindow.h"
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString sPath = "C:/";
dirModel = new QFileSystemModel(this);
dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
dirModel->setRootPath(sPath);
ui->treeView->setModel(dirModel);
ui->treeView->setColumnHidden(0, false);
ui->treeView->setColumnHidden(1, true);
ui->treeView->setColumnHidden(2, true);
ui->treeView->setColumnHidden(3, true);
fileModel = new QFileSystemModel(this);
fileModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
fileModel->setRootPath(sPath);
ui->listView->setModel(fileModel);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_treeView_clicked(const QModelIndex &index)
{
QString sPath = dirModel->fileInfo(index).absoluteFilePath();
ui->listView->setRootIndex(fileModel->setRootPath(sPath));
}