QSortFilterProxyModel dont filter my treeview



  • I used this code to my treeview display folders in my hard drive and this code works fine:

    @
    QString sPath = "E:/";

    dirModel = new QFileSystemModel(this);
    dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
    dirModel->setRootPath(sPath);
    
    ui->treeView->setModel(dirModel);
    

    @

    Now I want to add filter to above code and I wrote this code for that purpose, but it show me an empty treeview while I have "clips" folder in my root of E:/ drive. Am I doing something wrong? Thank you for help

    @
    QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);

    proxyModel->setSourceModel(dirModel);
    proxyModel->setFilterRegExp(QRegExp("clips", Qt::CaseInsensitive, QRegExp::FixedString));
    
    ui->treeView->setModel(proxyModel);
    

    @


Log in to reply
 

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