I am trying to create a file explorer in qt that works, but I cannot set the root path. I run Mac OS X and no matter what root path I embed, treeView always starts with
"/" top folder.
I spent 2 hours trying to figure it out.
if(QDir("SavedOutlines").exists()){ fileModel = new QFileSystemModel; QDir dir; QString rootpath = dir.absolutePath() + "/SavedOutlines/"; //QString path = "/Users/"; fileModel = new QFileSystemModel(this); QModelIndex idx = fileModel->setRootPath(rootpath); ui->treeView->setCurrentIndex(idx); ui->treeView->setModel(fileModel); ui->treeView->show(); }
It seems that he does this first, and then returns to the top of the page again //
dave_g_
source share