Sort System Drives via QSortFilterProxyModel



  • 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:)@

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.