Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:23:41+00:00 2026-06-15T22:23:41+00:00

I am working on Qt app where I need to display Filesystem inside a

  • 0

I am working on Qt app where I need to display Filesystem inside a Qtreeview. Basically my idea is to customize the filesystem in such a way that Removable Drives come under one section and Local Drives come under another. I tried to achieve it using QFSFileEngine but I have been successful to some extent. here is the code:

pSystemSecondaryModel = new QFileSystemModel(this);
pSystemSecondaryModel->setRootPath(QDir::currentPath());

list = QFSFileEngine::drives();
for(int i = 0; i < list.size(); i++)
{
    qDebug() << list.at(i).absoluteDir();
}

m_model = new QStandardItemModel(0,0);

QList<QStandardItem *> LocalItem;
LocalItem.insert(0,new QStandardItem("Local Drives"));
LocalItem.at(0)->setEditable(false);
m_model->insertRow(0,LocalItem);

QList<QStandardItem *> RemovableItem;
RemovableItem.insert(0,new QStandardItem("Removable Drives"));
RemovableItem.at(0)->setEditable(false);
m_model->insertRow(1,RemovableItem);

for (int i = 0; i < list.count(); i++)
{
    QString str = list.at(i).absolutePath();
    Localchild = new QStandardItem(str);
    QStandardItem* LocalparentItem = m_model->item(0,0);
    Localchild->setEditable(false);
    LocalparentItem->appendRow(Localchild);
}

QStandardItem* Removablechild = new QStandardItem();
QStandardItem* RemovableparentItem = m_model->item(1,0);
Removablechild->setEditable(false);
RemovableparentItem->appendRow(Removablechild);
ui->PrimTreeView->setModel(m_model);

When I run the app, it shows Local Drives and Removable Drives root node. Under Local Drive node, I find all C: D: E: etc as children whereas Removable Drive seems to be empty i.e. without any children.
Here is the scenario which is the current output:

- Local Drives
   C:/
   D:/
   E:/

- Removable Drives

But when I click on each drive, I am not able to see the subdirectories at all. Ideally when I click C:/ i should be able to see Windows, Program Files folder etc. Its totally empty. How can I achieve it? Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:23:42+00:00Added an answer on June 15, 2026 at 10:23 pm

    As you probably know, you are not using your QFileSystemModel at all, and simply populating a QStandardItemModel with manual entries that you look up.

    If your goal is to present custom groupings of file system listing, what you might try and do is use multiple QFileSystemModel instances, with roots set to each of your drives. So you would continue to set up the top level drives as you are doing, but for each of those drives you might need a model set to that root. And then create a map between those items and their private models.

    Then you would have to re-implement probably index, hasChildren, rowCount, columnCount, and maybe some other read-only methods, to check into the models of those drives. So if for instance the model needs to know if C:/ has children, your hasChildren() would have to look up the mapping of that index to the hidden C:/ root model, and do a child count on that model.

    Another way is to just subclass QStandardItemModel (or QAbstractItemModel) and do the file system listings yourself instead of using QFileSystemModel. This would allow you to just set your fixed root items, being the categories, and drive letters, and then check the listings as they are expanded or collapsed. Again this will require subclassing a model which is not always a great beginners Qt experience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an app that will need to display a coverflow style view
I am working on app where i need to display a tab bar controller
I am working on a Qt app where I need to display some UI
I working for an app that requires google login. I need to access provider_uid,
I am working on app where I need to display arabic text from a
I am working on a B2B portal web app, where i need to display
I'm working on an app that can display a graph with some data, one
I am now working on an android app in which I need to display
I'm working on a web app where I need to display a service mark
I'm working on a Cocoa Mac app where I need to display a window/view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.