Results 1 to 3 of 3

Thread: Running QSortFilterProxyModel outside of the GUI thread to speed things up?

  1. #1

    Default Running QSortFilterProxyModel outside of the GUI thread to speed things up?

    I've got a QAbstractItemModel being displayed in a QTreeView, and I'm filtering it using QSortFilterProxyModel.

    For the most part, things work okay, but the filtering is agonizingly slow. This in itself would be fine if I could just put up an hourglass and let the user know that the search is running, but the problem is that it's freezing up the whole GUI while the search is running.

    Is there any way to run the QSortFilterProxyModel outside of the GUI thread to avoid this problem, and then have the GUI update when the filtering is complete?

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Running QSortFilterProxyModel outside of the GUI thread to speed things up?

    I dont know, but it should be easy to test. Just make a QThread, start() it, and move the sort proxy to that thread. Bear in mind that only the proxy's slots will run in the new thread
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Running QSortFilterProxyModel outside of the GUI thread to speed things up?

    Moving the proxy model to an external thread just like that is not going to work.

    It's possible to do filtering in another thread but it requires much more work and QSortFilterProxyModel will be of little (if any) use here. One needs to trigger filtering, make a snapshot of the model, do the filtering in another thread and when it is done, update the proxy model with results of this operation. Alternative approach would be to use a 0-timeout timer to test consecutive rows for the filtering condition and if match is found, filter the item out in the proxy (without any extra threads). Both there approaches would not use QSortFilterProxyModel.
    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.


Similar Threads

  1. How to accelerate the running speed of the qt program?
    By superwave in forum Qt Programming
    Replies: 5
    Last Post: 20th June 2011, 05:03
  2. QThread not running in different thread
    By lauwe in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2011, 23:02
  3. recompiling Qt install with -ffast-math to speed things up ...
    By qt_gotcha in forum Installation and Deployment
    Replies: 1
    Last Post: 23rd February 2010, 19:27
  4. how to terminate a thread when it is running
    By guchangyuan in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2009, 10:50
  5. running() - Thread
    By sabeesh in forum Qt Programming
    Replies: 5
    Last Post: 9th October 2007, 18:45

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
  •  
Qt is a trademark of The Qt Company.