QT笔记- QTreeView + QFileSystemModel 当前位置的保存与恢复 #选中 #保存当前索引
保存当前位置
QString currentPath = model->filePath(view->currentIndex()); // 获得当前位置路径
恢复位置
view->setCurrentIndex(model->index(currentPath)); // 设置此路径所在位置为当前位置
QString currentPath = model->filePath(view->currentIndex()); // 获得当前位置路径
view->setCurrentIndex(model->index(currentPath)); // 设置此路径所在位置为当前位置