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 can I get QFileSystemModel to display directories beginning with a "." (dotfiles) e.g. /users/paulsmith/.dirName?

How can I get QFileSystemModel to display directories beginning with a "." (dotfiles) e.g. /users/paulsmith/.dirName?

Scheduled Pinned Locked Moved General and Desktop
qdirqfilesystemmodedotfiles
5 Posts 2 Posters 1.7k 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.
  • G Offline
    G Offline
    gshannon154
    wrote on 9 Apr 2015, 11:01 last edited by
    #1

    Hi,

    I am working in Unix and I want QFileSystemModel to display directories beginning with a "." (dotfiles) e.g. /users/paulsmith/.dirName as well as ordinary directories.

    I have:

    .h file:

    private:
    QFileSystemModel *dirModel;

    .cpp file:

    QString sPath = "/users/paulsmith/";
    dirModel = new QFileSystemModel(this);
    dirModel->setRootPath(sPath);
    dirModel->setFilter(QDir::AllDirs);

    ...but the last line above doesn't do what I want to achieve and I don't know what else will. Does anybody know how?

    Thanks,

    P 1 Reply Last reply 9 Apr 2015, 11:24
    0
    • G gshannon154
      9 Apr 2015, 11:01

      Hi,

      I am working in Unix and I want QFileSystemModel to display directories beginning with a "." (dotfiles) e.g. /users/paulsmith/.dirName as well as ordinary directories.

      I have:

      .h file:

      private:
      QFileSystemModel *dirModel;

      .cpp file:

      QString sPath = "/users/paulsmith/";
      dirModel = new QFileSystemModel(this);
      dirModel->setRootPath(sPath);
      dirModel->setFilter(QDir::AllDirs);

      ...but the last line above doesn't do what I want to achieve and I don't know what else will. Does anybody know how?

      Thanks,

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 9 Apr 2015, 11:24 last edited by p3c0 4 Sept 2015, 11:25
      #2

      @gshannon154 Try QDir::Dirs|QDir::Hidden or QDir::AllDirs|QDir::Hidden.

      157

      G 1 Reply Last reply 9 Apr 2015, 12:26
      0
      • P p3c0
        9 Apr 2015, 11:24

        @gshannon154 Try QDir::Dirs|QDir::Hidden or QDir::AllDirs|QDir::Hidden.

        G Offline
        G Offline
        gshannon154
        wrote on 9 Apr 2015, 12:26 last edited by
        #3

        @p3c0

        Thank you that has worked well! The only problem is that now no files are being displayed. Do you know how to fix this but still keep the dotfiles?

        Thanks,

        P 1 Reply Last reply 9 Apr 2015, 12:27
        0
        • G gshannon154
          9 Apr 2015, 12:26

          @p3c0

          Thank you that has worked well! The only problem is that now no files are being displayed. Do you know how to fix this but still keep the dotfiles?

          Thanks,

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 9 Apr 2015, 12:27 last edited by
          #4

          @gshannon154 Yes. Just add QDir::Files to it.

          157

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gshannon154
            wrote on 9 Apr 2015, 14:13 last edited by
            #5

            Brilliant thanks!

            1 Reply Last reply
            0

            3/5

            9 Apr 2015, 12:26

            • Login

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