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. access a file in the root path directory using QFileSystem hierarchy
Forum Updated to NodeBB v4.3 + New Features

access a file in the root path directory using QFileSystem hierarchy

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 471 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.
  • J Offline
    J Offline
    jventura 0
    wrote on last edited by
    #1

    Hi,
    I'm currently using the QFileSystemModel class and i just can't get the point of the row and column hierarchy. I got that the rows number defines the number of children. But what about the columns? What does it represent? I'm currently trying to set a new root path to the n°x child of a directory using its index but i just can't find this file using the row and column hierarchy that i naturally think of in the index(int row, int column, QModelIndex *parent) method which for me should be index(x,0 or 1 depending on 0-based or not, current root path file's index).

    I already thank you for your help.

    Jean

    1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      I haven't used QFileSystemHierarchy, and I don't fully understand what your issues are, so I could be out on this... :)

      I think it has columns as well as rows partly because it's derived from QAbstractItemModel. I imagine the columns are a file's attributes (name, size, date, ...)(?) I think you should ignore columns. QModelIndex is the key thing.

      • Just use functions like QString filePath(const QModelIndex &index) const to get values from an item at an index
      • and functions like QModelIndex index(const QString &path, int column = 0) const and QModelIndex setRootPath(const QString &newPath) to generate an index from a path. Note that these do not need a column, only a path.

      P.S.

      I'm currently trying to set a new root path to the n°x child of a directory

      Use children() (from base class, QAbstractItemModel) to access and iterate a directory's child files/directories. Nothing to do with row/column.

      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