I am using QFileSystemModel to represent file structure through the QTreeView. Everything works fine and it displays C:, D: etc drives in TreeView, but I need to add an additional row at the beginning of the tree. For example for now is:
+ C:
+ D:
+ E:
After adding the row ‘Local Drives’ at the beginning, I wanna display it like:
- Local Drive
+ C:
+ D:
+ E:
- Local Drive
+ C:
+ D:
+ E:
To copy to clipboard, switch view to plain text mode
Here is the code:
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel
->setRootPath
(QDir::currentPath());
ui->TreeView->setModel(pSystemPrimaryModel);
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel->setRootPath(QDir::currentPath());
ui->TreeView->setModel(pSystemPrimaryModel);
To copy to clipboard, switch view to plain text mode
Bookmarks