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 filter folder in treeview
Forum Updated to NodeBB v4.3 + New Features

How to filter folder in treeview

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 2.9k Views 2 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.
  • T Offline
    T Offline
    tako
    wrote on 14 Dec 2015, 13:47 last edited by tako
    #1

    http://i.hizliresim.com/LgMq1a.png
    I want to show just Bring2d folder on treeview

    ? 1 Reply Last reply 14 Dec 2015, 18:38
    0
    • T tako
      14 Dec 2015, 13:47

      http://i.hizliresim.com/LgMq1a.png
      I want to show just Bring2d folder on treeview

      ? Offline
      ? Offline
      A Former User
      wrote on 14 Dec 2015, 18:38 last edited by
      #2

      @tako

      The docs are a good place to start: QTreeView Class

          QFileSystemModel *model = new QFileSystemModel;
          model->setRootPath(QDir::currentPath());
          QTreeView *tree = new QTreeView(splitter);
          tree->setModel(model);
      
      T 1 Reply Last reply 14 Dec 2015, 18:53
      0
      • ? A Former User
        14 Dec 2015, 18:38

        @tako

        The docs are a good place to start: QTreeView Class

            QFileSystemModel *model = new QFileSystemModel;
            model->setRootPath(QDir::currentPath());
            QTreeView *tree = new QTreeView(splitter);
            tree->setModel(model);
        
        T Offline
        T Offline
        tako
        wrote on 14 Dec 2015, 18:53 last edited by
        #3

        @TOMATO_QT please give me example.
        my English is not enough :(

        ? 1 Reply Last reply 14 Dec 2015, 19:43
        0
        • T tako
          14 Dec 2015, 18:53

          @TOMATO_QT please give me example.
          my English is not enough :(

          ? Offline
          ? Offline
          A Former User
          wrote on 14 Dec 2015, 19:43 last edited by
          #4

          @tako

          This the example: model->setRootPath(path-to-directory-you-want-to-display);

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tako
            wrote on 14 Dec 2015, 20:05 last edited by
            #5

            this is not problem. problem is all show folders.
            I want to show I wanted folder

            ? 1 Reply Last reply 14 Dec 2015, 20:12
            0
            • T tako
              14 Dec 2015, 20:05

              this is not problem. problem is all show folders.
              I want to show I wanted folder

              ? Offline
              ? Offline
              A Former User
              wrote on 14 Dec 2015, 20:12 last edited by
              #6

              @tako

              ...show some effort?

              http://stackoverflow.com/questions/12357756/qfilesystemmodel-setrootpath

              T 1 Reply Last reply 14 Dec 2015, 20:24
              0
              • ? A Former User
                14 Dec 2015, 20:12

                @tako

                ...show some effort?

                http://stackoverflow.com/questions/12357756/qfilesystemmodel-setrootpath

                T Offline
                T Offline
                tako
                wrote on 14 Dec 2015, 20:24 last edited by
                #7

                @TOMATO_QT I could not tell .
                It will only appear in the root directory of your home folder
                so There will not be other folders . (e.g users - bin- etc.) just home folder

                ? 1 Reply Last reply 15 Dec 2015, 00:53
                0
                • T tako
                  14 Dec 2015, 20:24

                  @TOMATO_QT I could not tell .
                  It will only appear in the root directory of your home folder
                  so There will not be other folders . (e.g users - bin- etc.) just home folder

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on 15 Dec 2015, 00:53 last edited by
                  #8

                  @tako

                  Perhaps try one of these forums: https://forum.qt.io/category/36/international

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tekojo
                    wrote on 15 Dec 2015, 07:31 last edited by
                    #9

                    So you want to hide all the other folders?

                    Sounds a lot like:
                    https://forum.qt.io/topic/59973/how-do-i-limit-the-files-that-are-shown-in-qfiledialog

                    Also the file system model docs is a good place to look:
                    http://doc.qt.io/qt-5/qfilesystemmodel.html

                    Hope that helps!

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on 15 Dec 2015, 08:46 last edited by
                      #10

                      Unfortunately QFileSystemModel does not have a built-in way to filter out directories, only files. The reason is performance related to how file systems work.
                      To do directory filtering you could subclass a QSortFilterProxyModel and implement its filterAcceptsRow() method to pass through only the directory you want.

                      1 Reply Last reply
                      0

                      1/10

                      14 Dec 2015, 13:47

                      • Login

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