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. I don't understand QFileSystemModel architecture.

I don't understand QFileSystemModel architecture.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.6k 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.
  • W Offline
    W Offline
    wow505
    wrote on last edited by
    #1

    example :

    my fileSystem structure
    @
    A(driver) row = ???, parent-> ??? , Child -> folderA
    └ folderA : row = 0 , parent -> A(driver), Child -> folderB
    └ folderB : row = 0 , parent -> folderA, Child -> folderC
    └ folderC : row = 0 , parent -> folderB, Child -> NULL????

    C(driver) row = ???, parent-> ??? , Child -> folderE, folderD, folderF
    └ folderE : row = 0, parent-> C(driver) , Child -> NULL???
    └ folderD : row = 1, parent-> C(driver) , Child -> NULL???
    └ folderF : row =2, parent-> C(driver) , Child -> NULL???
    @

    I want to access "folderC" or "folderF" using by QFileSystemModel/QModelIndex

    I Try Coding

    trying ACCESS "FolderC" :
    @

    QFileSystemModel* fileSys = new QFileSystemModel;
    
    fileSys->setRootPath("A:");
    
    QModelIndex driverA = fileSys->index("A:");
    
    QModelIndex FolderA = fileSys->index(0,0,driverA ); //now currentIndex point "FolderA"??
    
    QModelIndex FolderB = fileSys->index(0,0,FolderA ); //now currentIndex point "FolderB"??
    
    QModelIndex FolderC = fileSys->index(0,0,FolderB ); //now currentIndex point "FolderC"????
    

    @

    trying ACCESS "FolderF" :
    @

    QFileSystemModel* fileSys = new QFileSystemModel;

    fileSys->setRootPath("A:");
    
    QModelIndex currentIndex = fileSys->index("C:");
    
    currentIndex = currentIndex.child(2,0); // Now, currentIndex point "FolderF"????
    

    @

    I study already Qt Doc 5.0(QFileSystemModel, QModelIndex, Model and View). but, I don't understand.

    I don't know what to do.. help..

    addition Question

    what does mean QFileSystemModel::setRootPath()??

    example :
    @
    QFileSystemModel* fileSys = new QFileSystemModel;

    fileSys->setRootPath("C:"); // <----- fileSys watching only "C: driver"?????
    @

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

      Your first example is nonsense. Calling index twice with the same arguments will give the same result (unless the model changed in the mean time).

      Your second example is close, but not quite it. You are saying that the root directory is A:, and then you want to have the item representing C:. However, C: is a sibling of A:, so C: is not going to show up if A: is your root. As you suspect at the bottom, you can limit what part of the file system QFSM represents (and watches). Just set an empty string instead, or use the classID of MyComputer (if you're on windows) as your root path.

      Note that I think you should not be using the model/view API outside of actually tweaking models, proxies or views. The API is just not ideal for direct use from your application.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wow505
        wrote on last edited by
        #3

        thanks for your suggestion
        In this case, how to access folder or directory??

        I want to some example..

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

          [[doc:QDirIterator]] would probably be a good start. But it really depends on what you want to do with the file system. What kind of access do you need?

          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