Results 1 to 5 of 5

Thread: how use QFileSystemModel with QListView ?

  1. #1
    Join Date
    Apr 2010
    Location
    Algeria
    Posts
    4
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows

    Default how use QFileSystemModel with QListView ?

    Hi friends,
    i use Qt jambi with eclipse and i have a small problem with QFileSystemModel ..... this model doesn't show me what i want exactly

    i just want to know how QFileSystemModel work to obtain this result

    went i select a folder in left side ( QTreeView ) i obtain the content of this folder in the right side ( in QListView )

    please help me ........



    thanks
    Last edited by lwifi; 12th April 2010 at 19:02.

  2. #2
    Join Date
    Apr 2010
    Location
    Algeria
    Posts
    4
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows

    Arrow Re: how use QFileSystemModel with QListView ?

    Hi, again
    here what i do to obtain a folder path
    Qt Code:
    1. public String selected_file(QModelIndex i)
    2. {
    3. String paren,child; //put the final path in child
    4.  
    5. QAbstractItemModel mdir = ui.treeView.model();
    6. Object dt = mdir.data(i);
    7. QModelIndex par = mdir.parent(i);
    8.  
    9. child = dt.toString();
    10. while(par != null)
    11. {
    12. paren = par.data().toString();
    13. child = paren +"/"+ child;
    14. par = par.parent();
    15. }
    16. return child;
    17. }
    To copy to clipboard, switch view to plain text mode 

    so, i want to show the files of this path in QListView with QFileSystemModel
    but i don't know how this model works !!!!!
    Qt Code:
    1. public void show_file(String path)
    2. {
    3.  
    4. QFileSystemModel std = new QFileSystemModel();
    5. QDir dir = new QDir(path);
    6. std.setRootPath(dir.path());
    7.  
    8. ui.listView.setUniformItemSizes(true);
    9. ui.listView.setModel(std);
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    but this function doesn't works °°
    thanks ...
    Last edited by lwifi; 13th April 2010 at 21:55.

  3. #3
    Join Date
    Apr 2010
    Location
    Algeria
    Posts
    4
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows

    Question Re: how use QFileSystemModel with QListView ?

    any thing ???

  4. #4
    Join Date
    Apr 2010
    Location
    Algeria
    Posts
    4
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows

    Thumbs up Re: how use QFileSystemModel with QListView ?

    Hi again
    i found the solution of this bug
    this's a part of code to display the content of a folder
    Qt Code:
    1. public void show_file(String Path)
    2. {
    3. //initialization of fileSystem Model and Dir path
    4. QFileSystemModel std = new QFileSystemModel();
    5. QDir dir = new QDir(path);
    6.  
    7. // to arrange the items
    8. ui.listView.setUniformItemSizes(true);
    9.  
    10. // join the model to the listView
    11. ui.listView.setModel(std);
    12. ui.listView.setRootPath(std.index(dir.path()));
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    Have a good time

  5. #5
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how use QFileSystemModel with QListView ?

    Line 12 of the code above: "setRootPath" is not a method of QListView, but a method of the QFileSystemModel. Can you please correct that line?

Similar Threads

  1. QFileSystemModel with checkboxes...
    By been_1990 in forum Qt Programming
    Replies: 14
    Last Post: 11th March 2011, 16:01
  2. Help with QFileSystemModel
    By TheShow in forum Qt Programming
    Replies: 4
    Last Post: 5th January 2010, 21:11
  3. Notifying QFileSystemModel about changes
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2009, 00:24
  4. QDirModel or QFileSystemModel?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2009, 18:10
  5. QFileSystemModel has no sorting
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2009, 09:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.