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. Filtering "NoDotDot" in filesystem model not working
Qt 6.11 is out! See what's new in the release blog

Filtering "NoDotDot" in filesystem model not working

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 5.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi ,
    I using filesystem model in my program to display the filesystems....
    Its working fine, it displays all the files and directoris including Dot and DotDot....
    But i dont want to display the "DotDot" hence i used filter as shown below, unfortunately its not working....IT DISPLAYS DOTDOT ALSO....
    Please somebody tell me whats wrong here...
    @ QString sPath=ui->lineEdit_directory->text();
    dirmodel =new QFileSystemModel(this);
    dirmodel->setFilter(QDir::AllDirs | QDir::Dirs |QDir::NoDotDot); <---HERE "QDir::NoDotDot" IS NOT WORKING

    dirmodel->setRootPath(sPath);
    ui->treeView->setModel(dirmodel);
    ui->treeView->setRootIndex(dirmodel->index(sPath));@
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Does it work if you replace QDir::AllDirs with QDir::Dirs?
      It seems to me that QDir::AllDirs conflicts with QDir::NoDotDot. I'm not entirely sure about that though.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Qt documentation says:

        bq. QDir::AllDirs 0x400 List all directories; i.e. don't apply the filters to directory names.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          [quote author="Andre" date="1336033688"]Does it work if you replace QDir::AllDirs with QDir::Dirs?
          It seems to me that QDir::AllDirs conflicts with QDir::NoDotDot. I'm not entirely sure about that though.[/quote]

          Ya i tried using as shown below......still it displays ".."(DotDot)
          @ dirmodel->setFilter(QDir::Dirs |QDir::NoDotDot);
          @

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            Hi,
            Try this code.

            @QString sPath ="c:/";
            dirModel = new QFileSystemModel(this);
            dirModel->setRootPath(sPath);
            dirModel->setFilter(QDir::NoDotDot | QDir::Dirs);
            ui->treeView->setModel(dirModel);
            ui->treeView->setRootIndex(dirModel->index(sPath));@

            Its the same as yours. but still works on my system, tested on windows 7.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              [quote author="Soumitra" date="1336035722"]Hi,
              Try this code.

              @QString sPath ="c:/";
              dirModel = new QFileSystemModel(this);
              dirModel->setRootPath(sPath);
              dirModel->setFilter(QDir::NoDotDot | QDir::Dirs);
              ui->treeView->setModel(dirModel);
              ui->treeView->setRootIndex(dirModel->index(sPath));@

              Its the same as yours. but still works on my system, tested on windows 7.
              [/quote]

              Oh thats crazy then....in mysystem its still showing "..", dont know where is the mistake....

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                Could you tell us, what system you're using?

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  [quote author="Andre" date="1336039264"]Could you tell us, what system you're using?[/quote]

                  its windows 7

                  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