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. [SOLVED] set path of QFileSystemModel
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] set path of QFileSystemModel

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.7k Views 1 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.
  • A Offline
    A Offline
    Abdeljalil
    wrote on last edited by
    #1

    i created a QFileSystemModel and a view
    i tried this:
    @fileSystemModel->setRootPath(QDir::homePath());@
    but even this the view continue to show the root path (/) in the view
    how to fix that?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You have it in QFileSystemModel's documentation:

      @tree->setRootIndex(model->index(QDir::currentPath()));@

      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
      • A Offline
        A Offline
        Abdeljalil
        wrote on last edited by
        #3

        @
        fileSystemModel = new QFileSystemModel(this);
        ui->fileSystemView->setModel(this->fileSystemModel);
        fileSystemModel->setRootPath(QDir::homePath());
        ui->fileSystemView->setRootIndex(fileSystemModel->index(QDir::currentPath()));
        @
        now nothing is showing in the view at all, empty view!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You are setting the model's root path to QDir::homePath() and the view's root index to the index of QDir::currentPath()

          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
          • A Offline
            A Offline
            Abdeljalil
            wrote on last edited by
            #5

            sorry, i'm new to that
            what should i do exactly?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Use homePath in both cases

              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

              • Login

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