SetRootPath with QT, QFileSystemModel on Mac OS X

I'm trying to create a file explorer in qt which is working but I cannot set the root path. I am running Mac OS X and no matter what root path I put in, the treeView always begins with

 "/" the top folder.

I've spent 2 hours trying to figure this out.

        fileModel = new QFileSystemModel;
        QDir dir;
        QString rootpath = dir.absolutePath() + "/SavedOutlines/";
        //QString path = "/Users/";
        fileModel = new QFileSystemModel(this);

        QModelIndex idx = fileModel->setRootPath(rootpath);

Open in new window

It seems like it's doing it at first but then resetting back to the top directory.
Who is Participating?
falimoradConnect With a Mentor Author Commented:
Doesn't work.

I found that the below code works:

QDir directory;
    directory.setPath(directory.absolutePath() + "/SavedOutlines/");
    //removes the . and .. folders
    delete ui->listWidget->item(0);
    delete ui->listWidget->item(0);

Open in new window

Stupid question - what happens if you try that with a hard-coded path?
falimoradAuthor Commented:
This works to populate a list of files in a folder.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.