当前位置: 代码迷 >> QT开发 >> 请问一个关于QFileSystemModel的效率有关问题
  详细解决方案

请问一个关于QFileSystemModel的效率有关问题

热度:59   发布时间:2016-04-25 04:54:07.0
请教一个关于QFileSystemModel的效率问题
一个文件浏览器,自定义了一个model继承QFileSystemModel,重写了它的data函数,实现了在列上显示自己想要的信息,但是发现一个严重的效率问题,就是移动滚动条的时候,data被多次调用,有多少列,就被调用了多少次,在pc上还好,可是到了开发板上速度就显得很慢了,求教一下,为什么这个data函数会被调用多次,怎么才能提高效率呢

------解决方案--------------------
你可以考虑下面的因素
The main advantage of QFileSystemModel is its thread: the model is populated asynchronously by a gatherer thread.
Caching and Performance
QFileSystemModel will not fetch any files or directories until setRootPath() is called. This will prevent any unnecessary querying on the file system until that point such as listing the drives on Windows.
Unlike QDirModel(obsolete), QFileSystemModel uses a separate thread to populate itself so it will not cause the main thread to hang as the file system is being queried. Calls to rowCount() will return 0 until the model populates a directory.
QFileSystemModel keeps a cache with file information. The cache is automatically kept up to date using the QFileSystemWatcher.
  相关解决方案