1

I apologize in advance for my English. I have QTableView with QFileSystemModel as model in my simple two-panel file manager. It displays files and directories correctly, but I want it to display DotDot line to move to the parent of the current directory. Setting QFileSystemModel::filter(QDir::AllEntries | QDir::NoDot) doesn't help, DotDot still doesn't display in QTableView. All of the above is true for Qt 5.9.1 on Windows 7. But when I build app on Ubuntu, it displays DotDot correctly, and QFileSystemModel::filter() perfectly works depending on it's arguments. Am I able to make it work on Windows 7 or it's a bug? Here's simplified sample of my code:

    QTableView *tableView = new QTableView;
    QFileSystemModel *fsModel = new QFileSystemModel;
    fsModel->setRootPath(QDir::rootPath());
    fsModel->setFilter(QDir::AllEntries | QDir::NoDot);
    tableView->setModel(fsModel);
    QObject::connect(tableView, &QTableView::doubleClicked, tableView, &QTableView::setRootIndex);
    tableView->show();

1 Answers1

0

Make own class inherited from QFileSystemModel. And redefine virtual methods rowCount() and data(). That not simple way, but allow good control about content that show with that model. Of course you can add Dot and DotDot ( and even DotDotDotDot : ) )directories.

stanislav888
  • 374
  • 2
  • 9