Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Sort System Drives via QSortFilterProxyModel

    General and Desktop
    1
    1
    608
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Stoned Jesus last edited by

      I just want to know which function of QSortFilterProxyModel class is used to sort the local and removable drives in system. Basically I am working on a app where I am using treeview and I need to sort them in a order.

      Here is the code:
      @pSystemPrimaryModel = new QFileSystemModel(this);
      pSystemPrimaryModel->setRootPath(QDir::currentPath());
      pSystemPrimaryModel->setFilter( QDir::AllDirs | QDir::NoDotAndDotDot );

      // Sets the model for the view to present.
      ui->PrimTreeView->setModel(pSystemPrimaryModel);

      // Just Display NAME and hide other Columns
      for(int nCount = 1; nCount < pSystemPrimaryModel->columnCount(); nCount++)
      ui->PrimTreeView->hideColumn(nCount);@

      This displays drives in a regular manner as follows:
      @Name:

      • C:
      • New Volume(D:)
      • New Volume(E:)
      • SD_Card(F:)
      • Transcend Drive(G:)@
        Basically I want to display it like follows:
        @+ Local Folder
        • C:
        • New Volume(D:)
        • New Volume(E:)
      • Removable Drives
        • SD_Card(F:)
        • Transcend Drive(G:)@

      --
      Thanks & Regards,
      Stoned Jesus

      1 Reply Last reply Reply Quote 0
      • First post
        Last post