c++ - QFileSystemModel - Incremental update/pre-emptive update -
From Qt documentation:
QFileSystemModel setRootPath will not fetch any files or directories () Is called. This file will prevent any unnecessary inquiries on the system unless the drives in Windows are listed in it. Unlike QDirModel (obsolete), QFileSystemModel uses a different thread to populate itself, so it will not cause the main thread to be questioned as a file system for hanging. To call the rowCount () will return to 0 until the model does not populate any directory. QFileSystemModel keeps a cache with file information Caffei keeps up to date using QFileSystemWatcher automatically.
I am using QTreeView with a subclassified QFileSystemModel which uses the check box.
If I get '0' before I expand an item in theQFileSystemModel :: rowCount (index) tree, even if there are no subdirectories or files or not However, once it is expanded into the correct line count it will be called again.
I think if you call QFileSystemModel :: setRootPath (), then it will receive data from the specified file path, but it seems that before I code
QFileSystemModel :: Calling rowCount (Cash not updated) does not perform 'fast enough'. MyModel :: setData (const QModelIndex and index, const QVariant and value, int role) whenever the checkbox is clicked in a TreeView {if (role == Qt: : CheckStateRole) {if (value == Qt :: checked) {setRootPath (this-> FilePath (index)); Checklist.insert (index); Set_children (index); } Else {checklist.remove (index); Unchecklist- & gt; Insert (index); } Data throwing changed (index, index); Back true; } Return QFileSystemModel :: setData (index, value, role); } // calculates how many items / nodes (i.e. file / folders) are null MyModel :: set_children (const QModelIndex and index) {int row = this- & gt; Panditika (index); QDebug () & lt; & Lt; QString :: number (line); }
Before knowing how many items have been included in that folder, before knowing that I can gather sub-folder information?
Thanks <
QFileSystemModel emits signal when thread is expiring Loading directory.
Comments
Post a Comment