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] Hide inactive files QTreeView
QtWS25 Last Chance

[SOLVED] Hide inactive files QTreeView

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

    Hello guys. I know this is a very discussed problem in internet, but i've tried a lot without success. Here follows my code:

    @dirmodel = new QFileSystemModel(this);

    QStringList filters;
    filters << "*.xml";
    dirmodel->setNameFilters(filters);
    
    this->ui->treeView->setModel(dirmodel);
    this->ui->treeView->setColumnHidden(1, true);
    this->ui->treeView->setColumnHidden(2, true);
    this->ui->treeView->setColumnHidden(3, true);
    
    this->ui->treeView->setRootIndex(
                dirmodel->setRootPath(
                    this->workspacepath
                    )
                );@
    

    This code was created to show only .xml files in QTreeView. But it only set other extensions as inactive (like image below). How do i hide all this inactive files?

    !https://dl.dropboxusercontent.com/u/45191488/2.png(image)!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Look at the QFileSystemModel::setNameFilterDisables()

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leandrogs
        wrote on last edited by
        #3

        It works. Thank you. :)

        [quote author="ChrisW67" date="1372146434"]Look at the QFileSystemModel::setNameFilterDisables()[/quote]

        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