Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Updating QListView from aggrigation thread make the GUI stuck
Qt 6.11 is out! See what's new in the release blog

Updating QListView from aggrigation thread make the GUI stuck

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Hello all
    I have simple application that build like this
    Mainwindow hold QListView using QAbstractListModel
    When I start the application I start single thread using thread worker
    That its job is get data records from external web service , it gets 10 -20 records on each
    Iteration .
    Now the problematic part :
    In the HttpAggrigator class that started from the thread worker
    In the big while loop that iterate on each returned record
    I emit signal to another class that called ViewControler and its job is populate To the QListView Model
    In this part my window just freeze until all the items are set in the listview.
    I checked with the profiling tool called "Sleepy" and indid in the ViewControler method that sets the items
    Is cousing the slow down.
    My question is how should I do it right so that item will be added in lightweight way

    The flow:
    MainWindow -> start HttpAggrigator (in different thread )
    HttpAggrigator -> get records -> start iterate them ( to fill data objects )
    HttpAggrigator -> emit signal to ViewControler on each records iteration to build item into MainWindow QListView

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      look at QCoreApplication::processEvents(), it is alot like doEvents() in visual basic (if you are familiar with it).
      http://developer.qt.nokia.com/doc/qt-4.8/qcoreapplication.html#processEvents

      Also, a recommendation. If an object is created in the mainwindow application, it should only be edited from the main window. So, instead of emiting the signal to slot in ViewController, do it in your main application. Or emit another signal from your ViewController, that slots to the mainwindow and updates the listview.

      If your httpaggigator is in its own thread, then im assuming the population in the QListView is what is slowing it down.

      Mainwindow->httpaggrigator
      httpaggrigator->viewcontroller
      viewcontroller->mainwindow (update listview).

      And in any while loops (which I am assuming is what is slowing down the gui), use QCoreApplication::processEvents() which will alow the form to update...

      I could be misunderstanding how your using your classes, but this is Just a suggestion!

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        where should i put the QCoreApplication::processEvents()
        i think you understand it right maybe should i also use beginInsertRows in the model?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved