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 - QFileSystemModel setRootPath
Forum Updated to NodeBB v4.3 + New Features

SOLVED - QFileSystemModel setRootPath

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

    I am attempting to create a Qt application which shows the contents of a folder ("Users" folder in Mac OS).
    Here is the code:
    @ QFileSystemModel *dirModel = new QFileSystemModel;
    dirModel->setRootPath("/Users");

    ui->listView->setModel(dirModel);
    

    @

    When i run the application, instead of showing the content of the "/Users" Folder, it shows the root drive (note: not the content of the drive). The folder does exist and i also tried using other folders.

    Thanks in advance!

    Your Counter Number:# 552473

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BZaidan
      wrote on last edited by
      #2

      I have solved the issue using this code :
      @ QFileSystemModel *dirModel = new QFileSystemModel(this);

      ui->listView->setModel(dirModel);
      ui->listView->setRootIndex(dirModel->setRootPath("/Users"));
      

      @

      Your Counter Number:# 552473

      1 Reply Last reply
      1

      • Login

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