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

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -