Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Want to show only Name column of QFileSystemModel in QTreeView ..

[SOLVED] Want to show only Name column of QFileSystemModel in QTreeView ..

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 12.3k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    HI All,
    I want to show only Name Coulmn of QFileSystemModel in QTreeView
    my codes are here
    @
    CTestDlg::CTestDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);

    model = new QFileSystemModel(this);
    model->removeColumn(1); // for removing Size Column
    model->removeColumn(2);// for removing Type Column
    model->removeColumn(3);// for removing Date Modified Column
    
    model->setFilter(  QDir::NoDotAndDotDot | QDir::AllDirs);
    
    
    ui->treeLocalFolders->setRootIsDecorated( true );
    
    QModelIndex homeIndex = model->index(model->myComputer().toString());
    
    
    QString home_path = model->filePath(homeIndex);
    QModelIndex root_index = model->setRootPath(home_path);
    
    proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel( model );
    proxyModel->removeColumn(1); // for removing Size Column
    proxyModel->removeColumn(2);// for removing Type Column
    proxyModel->removeColumn(3);// for removing Date Modified Column
    
    ui->treeLocalFolders->setModel(proxyModel);
    ui->treeLocalFolders->setRootIndex(homeIndex);
    

    }
    @

    Even after removing the corresponding coulmn from QfileSystemModel & QSortFilterProxyModel
    it was not getting removed from the QTreeView..

    Please let me know whether i am doing anything wrong on this...

    1 Reply Last reply
    1
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Have you tried QTreeView::hideColumn()?

      1 Reply Last reply
      2
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        Wow..its wounderfull...
        Thanks for your valuable inputs...

        Its working fine now..

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved