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. How to hide the content from a directory in QFileSystemModel

How to hide the content from a directory in QFileSystemModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 800 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.
  • L Offline
    L Offline
    Laurent Schall
    wrote on last edited by
    #1

    Hi,

    I am using the QFileSystemModel model data model for the local filesystem.

    I would like to hide the content from a specific directory - not the name of the directory itself, but solely it content (files and sub-directories). I assume that setting a filter is not going to work, so that I will have to subclass some of the functions inherited QAbstractItemModel.

    What would be the best way to archive that.

    Thanks,
    Laurent

    JonBJ kshegunovK 2 Replies Last reply
    0
    • L Laurent Schall

      Hi,

      I am using the QFileSystemModel model data model for the local filesystem.

      I would like to hide the content from a specific directory - not the name of the directory itself, but solely it content (files and sub-directories). I assume that setting a filter is not going to work, so that I will have to subclass some of the functions inherited QAbstractItemModel.

      What would be the best way to archive that.

      Thanks,
      Laurent

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Laurent-Schall
      You can subclass from QFileSystemModel, which should be used to achieve this, so why think about dropping down to QAbstractItemModel?

      1 Reply Last reply
      3
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        subclass QFileSystemModel, and reimplement both rowCount() and hasChildren() to rerurn 0/false for the foder you want to hide the contents of

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        3
        • L Laurent Schall

          Hi,

          I am using the QFileSystemModel model data model for the local filesystem.

          I would like to hide the content from a specific directory - not the name of the directory itself, but solely it content (files and sub-directories). I assume that setting a filter is not going to work, so that I will have to subclass some of the functions inherited QAbstractItemModel.

          What would be the best way to archive that.

          Thanks,
          Laurent

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @VRonin said in How to hide the content from a directory in QFileSystemModel:

          subclass QFileSystemModel

          Or subclass QIdentityProxyModel, modify it as you want (i.e. what the fellows above suggested) and attach it to the standard QFileSystemModel.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          3

          • Login

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