Results 1 to 2 of 2

Thread: Updating directory view in a QListView

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Updating directory view in a QListView

    Hi there!

    I'm trying to display the contents of a directory in a QListView. It works great like this:

    Qt Code:
    1. QDirModel *model = new QDirModel;
    2. ui.configFileList->setModel(model);
    3. ui.configFileList->setRootIndex(model->index("config"));
    To copy to clipboard, switch view to plain text mode 

    But the view doesn't update when I write a file into that directory or drop something there in a file manager. I thought that was the whole model view thing all about. I also tried explicitly calling update() on the widget, nothing. Now after reading the docs and taking a look at the Directory View example to no avail, please help me to make my directory view update automagically.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Updating directory view in a QListView

    Use QFileSystemModel instead of QDirModel. The former is kept up to date using QFileSystemWatcher.

  3. The following user says thank you to wysota for this useful post:

    Cruz (8th February 2009)

Similar Threads

  1. Replies: 1
    Last Post: 14th January 2009, 10:10
  2. QListView not updating
    By Terabyte in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2009, 07:10
  3. install help nedded.
    By aj2903 in forum Installation and Deployment
    Replies: 9
    Last Post: 13th November 2008, 07:57
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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.