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 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,

    p3c0P 1 Reply Last reply
    0
    • G gshannon154

      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,

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

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

      157

      G 1 Reply Last reply
      0
      • p3c0P p3c0

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

        G Offline
        G Offline
        gshannon154
        wrote on 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,

        p3c0P 1 Reply Last reply
        0
        • G gshannon154

          @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,

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on 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 last edited by
            #5

            Brilliant thanks!

            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