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
|
//mainwindow.h
class MainWindow : public QMainWindow{
...
private:
QFileSystemModel *model;
private slots:
void onRootPathChanged(QString path);
...
};
//mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
{
model = new QFileSystemModel;
model->setRootPath(QDir::currentPath());
ui->treeView.setModel(model);
connect(ui->SimuFolderPathLineEdit, &QLineEdit::textChanged, this, &MainWindow::onRootPathChanged);
...
}
void MainWindow::onRootPathChanged(QString path){
model->setRootPath(path);
} |
Partager