Results 1 to 15 of 15

Thread: QListView not displaying all directory files

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Talking QListView not displaying all directory files

    Im settings the QListView's index:
    Qt Code:
    1. QString directory = "C:\\Users\\Username\\Desktop";
    2. ui->list->setRootIndex(model.index(directory));
    To copy to clipboard, switch view to plain text mode 

    But it displays only 101 items as opposed to 143 showing on explorer.exe(I know, Im messy ....) Any idea as to why?

    Update: I found out that the files not displayed are Windows shortcut files. Including Recycle Bin, My Computer & others.
    Last edited by been_1990; 5th May 2009 at 04:23.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView not displaying all directory files

    Try to set the model filter with QDirModel::setFilter()
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    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: QListView not displaying all directory files

    It would be good to know how the model is setup and what is the actual model class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    Qt Code:
    1. private:
    2. QDirModel model;
    To copy to clipboard, switch view to plain text mode 
    Thats how I put it in my class.

  5. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView not displaying all directory files

    Did you try setting resolve symlinks to true ? QDirModel::setResolveSymlinks()?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  6. #6
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    Tried both :
    Qt Code:
    1. model.setFilter(QDir::AllEntries);
    2. model.setResolveSymlinks(true);
    To copy to clipboard, switch view to plain text mode 
    Still the same. Some shorcuts appear but others dont, missing 30 or more files...
    Last edited by been_1990; 5th May 2009 at 16:20.

  7. #7
    Join Date
    Apr 2008
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView not displaying all directory files

    Quote Originally Posted by been_1990 View Post
    Im settings the QListView's index:
    Qt Code:
    1. QString directory = "C:\\Users\\Username\\Desktop";
    2. ui->list->setRootIndex(model.index(directory));
    To copy to clipboard, switch view to plain text mode 

    But it displays only 101 items as opposed to 143 showing on explorer.exe(I know, Im messy ....) Any idea as to why?

    Update: I found out that the files not displayed are Windows shortcut files. Including Recycle Bin, My Computer & others.
    iirc from my windows days (been quite a few years) items such as Recycle Bin, My computer, etc are not items in the file system. I think the terminology is Windows Shell NameSpace, but googling should give you some code to work with.

    You'll need to create a model to traverse the NameSpace using the Windows api.

  8. #8
    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: QListView not displaying all directory files

    I'd try QFileSystemModel first.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    Current code:
    Qt Code:
    1. QFileSystemModel model;
    2. QString directory = "C:\\Users\\Username\\temp files\\";
    3. ui->list->setRootIndex(model.setRootPath(directory));
    To copy to clipboard, switch view to plain text mode 
    In this directory I have 69 Windows shortcuts. But my QListView shows only 68 . And if I doube the amount I am missing 2 shortcuts.
    Im using Vista, could be the cause? Probably not...

  10. #10
    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: QListView not displaying all directory files

    What exactly is missing?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    I checked each file and the ones not shown where Recycle Bin, PGP Shredder and shortcut, "Vista Shortcut Manager" shortcut and SUPER © Uninstall shortcut. Apparently it doesn't show some shortcuts, I checked their properties and apparently they had no difference.
    When pointed to my Pictures folder it doesnt show "Sample Pictures" shortcut. So it probably is a Windows-managed-shorcut problem.

  12. #12
    Join Date
    Apr 2008
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView not displaying all directory files

    Quote Originally Posted by been_1990 View Post
    I checked each file and the ones not shown where Recycle Bin, PGP Shredder and shortcut, "Vista Shortcut Manager" shortcut and SUPER © Uninstall shortcut. Apparently it doesn't show some shortcuts, I checked their properties and apparently they had no difference.
    When pointed to my Pictures folder it doesnt show "Sample Pictures" shortcut. So it probably is a Windows-managed-shorcut problem.
    You still need to use the Shell Namespace API if you want these "folders" on windows;

    http://msdn.microsoft.com/en-us/libr...90(VS.85).aspx

    A quick search came up this which gives a C++ example.

  13. #13
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    So.. thats really the only way? I didnt quite understand how to pass that to QT. I get quite confused reading MSDN documentation.It would be better if there were a QT way..

  14. #14
    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: QListView not displaying all directory files

    The thing is that this is out of scope of the model. Those icons are not in the filesystem, they are fake icons created on the fly by Windows Explorer (or actually the Windows desktop probably). The model, on the other hand, contains contents of the file system.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView not displaying all directory files

    Okay. Thats understood. So the Recycle Bin and PGP Shredder appear at startup. They are "fake" icons. But what about the "Vista Shortcut Manager" shortcut and SUPER © Uninstall shortcut not appearing? They are not made on the fly and are a true "file".

Similar Threads

  1. Replies: 0
    Last Post: 19th February 2009, 14:32
  2. Updating directory view in a QListView
    By Cruz in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2009, 23:48
  3. directory and files
    By rmagro in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2008, 13:40
  4. [QT4] Counting files in a directory (Linux)
    By ucntcme in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2007, 22:59
  5. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.