How to initialize the starting path in Qt treeview? -


I want to initialize the early pioneers in QT Trywuv the User Home on Linux Ubuntu.

image here

I tried this code But that does not work.

QString spath = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"; Dirmodel = New QFileSystemModel (this); Dirodel-> Set filter (QDir :: NoDotAndDotDot | QDir :: AllDirs); Dirmodel- & gt; SetRootPath (sPath); UI- & gt; TreeView-> SetModel (dirmodel);
  • I have tested spath:
    1. / home /
    2. $ {HOME}
    3. / home / Kaspr / Music

Nobody does anything. = [

How to solve this?

Thank you for your help.

model setRootIndex Calling is required:

  ui-> treeView-> SetRootIndex (dirmodel-> Index ("/ home / Casper"));  

or for any home directory (also works on Windows, OSX, etc.):

  ui- & gt; Tree view-> Setter Index (Darmodel-> Index (QDir :: HOMEPATH ());  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -