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. QFileSystemModel root path
QtWS25 Last Chance

QFileSystemModel root path

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k 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
    Jake007
    wrote on last edited by
    #1

    Hi!

    I'm using QFileSystemModel with Tree View model to show file system structure.
    But I'd like to show only it only from users directory (QDir::homePath()), not entire file structure (all drives and onwards).

    In docs I've found only QFileSystemModel::setRootPath() method, but it only install watcher ( which takes ages to load). I've also noticed that mentioned method returns QModelIndex, but I don't know what to do with it.

    Note: I'm very new to models.

    Regards,
    Jake


    Code is poetry

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      As you already said, QFileSystemModel::setRootPath() only defines the path where the watcher will be installed, not the root of the file system hierarchy. What you want to do should be achieved by configuring the View to only show a sub-set of the Model, not by trying to modify the Model itself. Give QTreeView::setRootIndex() a try!

      You can use QFileSystemModel::index(const QString &path) to get the QModelIndex of the QDir::homePath() ;-)

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jake007
        wrote on last edited by
        #3

        Thanks!

        It works :) .
        As you said, I was searching in the wrong place.

        Marked as solved.

        Regards,
        Jake


        Code is poetry

        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