i have a QTreeView ,and its pointing to some location, so i can see all the folders which are in that location . By default all the sub folders are in collapse mode how to make it to EXTENDED mode
i have a QTreeView ,and its pointing to some location, so i can see all the folders which are in that location . By default all the sub folders are in collapse mode how to make it to EXTENDED mode
QFileSystemModel *model = new QFileSystemModel;
model->setRootPath(QDir::currentPath());
QString strPath ="/home/Desktop/PATHS";
ui->treeView->setItemsExpandable(true);
ui->treeView->setModel(model);
ui->treeView->setRootIndex(model->index(strPath));
ui->treeView->expandAll();
i tried these too but it din't work.
Since QFileSystemModel works in an asynchronous fashion, you need to call expandAll() only after QFileSystemModel::directoryLoaded() signal is emitted for the directory you need. Alternatively you can connect to that signal and upon receiving the path that has been completed, convert it to QModelIndex using QFileSystemModel::index() and then call QTreeView::expand() on the calculated index. Then you'll be expanding directories as they are being scanned.
Bookmarks