PYQT5 - Populating Model from Thread / Sorting large Tree advice



  • Hi All

    I'm learning PyQT5, so I've set myself the challenge of building a "TreeSize" replica (the famous Windows app for identifying disk usage). I've got a non-threaded version working, recursing the filesystem and populating a QTreeWidget, but its slow and freezes the UI when scanning and sorting (due to the volume of Items).

    So I'm looking for example code or advice on the following:

    • Populating a model large amounts of data that is being generated from a separate QThread.

    • Sorting the model / tree without it freezing the OS

    I've very much appreciate any help to point me in the right direction.. I did ask a similar question elsewhere, and they said QFileSystemModel was threaded, but I can't see it or I think they were referring to the C++ version!

    Many thanks


  • Lifetime Qt Champion

    Hi,

    They were right, QFileSystemModel is indeed threaded. Note that all PyQt 5 classes are wrappers around Qt's C++ classes.

    What is usually done when having lots of data is to process them by batch so that you don't overload your main thread.



  • @SGaist so is the threading in "QFileSystemModel" (The Python wrapper) done in the Python code or inside the QT library? I'm looking for some example code to show an approach this, I've got a few ideas, but probably not very workable.


  • Lifetime Qt Champion

    PyQt is a wrapper on top of Qt, what happens within the Qt classes is on the C++ side.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.