PDA

View Full Version : QFileSystemModel hangs GUI on Windows



lexsan
12th July 2013, 13:40
m_pqFileSystemModel = new QFileSystemModel;
m_pqFileSystemModel->setRootPath( QDir::rootPath() );
ui->qtvTreeView->setModel( m_pqFileSystemModel );

GUI hangs on creation, and on subsequent expands of folders with large number of files.
Anyone know how to speed things up ( on windows ) ?
The problem is that a lot of work is being done on the GUI thread (don't know if all is just graphics or some work is done as well).

Moving the QFileSystemModel object in a different thread solves the speed problem, but after a while the application crashes under a memory access violation exception.
This problem is old as Qt and no answer is in given to date as to how to circumvent the problem.

Santosh Reddy
12th July 2013, 13:49
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.
So it must be somthing with you application.

Also try setting the root path after QFileSystemModel::directoryLoaded() is emitted.