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. Delete a selected folder and all sub folders in QTreeView

Delete a selected folder and all sub folders in QTreeView

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.6qtreeviewdeleteremoverowqfilesystemmode
4 Posts 2 Posters 2.3k 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.
  • P Offline
    P Offline
    Punit
    wrote on 29 May 2016, 19:28 last edited by Punit
    #1

    Hello All,

    I am using QTreeView with QFilesySystemModel. How can I delete a selected folder along with all it's sub folders in QTreeView?

    CODE

     QModelIndex index=mytreeview->currentIndex();
      dirmodel->removeRows(index.row(), index.column(), index.parent());
    

    Any suggestions??
    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 May 2016, 20:47 last edited by
      #2

      Hi,

      QFileSystemModel::rmdir is what you are looking for. Beware of the warning in the documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Punit
        wrote on 30 May 2016, 07:25 last edited by
        #3

        I only want to remove folders from the QTreeview not from the file system. rmdir will remove my folder permanently from my system. @SGaist

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 30 May 2016, 07:27 last edited by
          #4

          That wasn't really clear from your original description.

          In that case, use a filter. QSortFilterProxyModel for example

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          4/4

          30 May 2016, 07:27

          • Login

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