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. [Solved] Showing "loading" animation while updating the QGraphicsScene (thread problem)
Forum Updated to NodeBB v4.3 + New Features

[Solved] Showing "loading" animation while updating the QGraphicsScene (thread problem)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.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.
  • T Offline
    T Offline
    teomurgi
    wrote on last edited by
    #1

    Hi all,

    I'm using Qt 4.8.

    I have a big QGraphicsScene to update (it takes 3 secs to append the new QGraphicsObjects).
    I would like to show the user that the update is in progress.
    In particular I thought about showing a loading wheel on screen and than remove it when the update ends.

    The problem here is that I should make the wheel visible and then not visible in the
    same thread of the scene update. This because:

    • It is not allowed to edit graphic properties outside the gui thread.

    • I cannot move the computation in a "worker thread" since it involves graphics.

    This results in the wheel not showing at all, since when the view is updated the wheel
    has been already set visible and then not visible again:

    @
    showWheel();
    /... big computation involving graphics .../
    hideWheel();
    /... here GUI is updated, thus the wheel doesn't show up.../
    @

    Is there anything I can do?

    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      One option is to call "qApp->processEvents":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#processEvents at regular intervals (e.g. inside a loop) during your "big computation" phase.

      See "this article":http://www.informit.com/articles/article.aspx?p=1405544&seqNum=3 also.

      http://www.goblincoding.com

      1 Reply Last reply
      0
      • T Offline
        T Offline
        teomurgi
        wrote on last edited by
        #3

        Thanks for the tips, it works and the article is very interesting.

        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