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



  • 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...



  • Have you tried QTreeView::hideColumn()?



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

    Its working fine now..


Log in to reply
 

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