I found this code on my machine:
Qt Code:
  1. // In constructor...
  2. root = dirModel->index(QDir::currentPath());
  3. listView->setRootIndex(root);
  4.  
  5. // later...
  6. void MainWindow::up_button_clicked()
  7. {
  8. root = root.parent();
  9. listView->setRootIndex(root);
  10. }
  11.  
  12. void MainWindow::listview_double_clicked(QModelIndex index)
  13. {
  14. if (static_cast<const QDirModel *>(index.model())->isDir(index))
  15. {
  16. root = index;
  17. listView->setRootIndex(root);
  18. }
  19. else
  20. {
  21. // do something with clicked file.
To copy to clipboard, switch view to plain text mode