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. Animating a Delegate

Animating a Delegate

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 132 Views 2 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.
  • P Offline
    P Offline
    peter.thompson
    wrote last edited by peter.thompson
    #1

    Is there a standard way to animate a delegate?

    I want to create a delegate that shows an item in a loading state. There are three possibilities for the state of the item: Unloaded, Loading, or Loaded. While the item is in the Loading state, I want the delegate to show an animated spinning wheel. (Note that I don't have actual progress for how far loaded the item is. I just know that it is in a Loading state.)

    Is it possible for a delegate to be animated like that? Do I need to constantly emit dataChanged() from the model to force the delegate to be repainted? Or is there a way for the delegate to force itself to be repainted every frame (or on a repeating timer), without relying on the model emitting a dataChanged() signal?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      How many items are you expecting to show at a given time ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How many items are you expecting to show at a given time ?

        P Offline
        P Offline
        peter.thompson
        wrote last edited by peter.thompson
        #3

        @SGaist In a usual case, I wouldn't expect to show more than fifty at once. There may be some edge cases where I show a few hundred.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          Then I wouldn't recommend showing fifty to several hundreds spinning wheels at the same time. Not that it's not doable but this sounds like a waste of resources.
          In any case, one possible way to implement that is to do the painting yourself and have a timer at the model level that triggers every so often incrementing a number that would correspond to the number of points you want to show.
          Another possible way to do that, that is also less complicated, is to simply have your model return Loading ., Loading.., Loading... and loop on that (or more dots).
          It's also a sort of animation but you don't need a special delegate.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Axel SpoerlA Online
            Axel SpoerlA Online
            Axel Spoerl
            Moderators
            wrote last edited by
            #5

            Adding to @SGaist: Maybe a progress bar delegate is a better alternative. While showing both the loading state and the progress, you don’t need permanent signal emissions. If it’s minuscule, it needs no more than 10-15 updates between 0 and 100%.
            Theoretically, if you get hold of its pointer, you could even update it from outside the model, e.g. from a worker thread with a signal/slot connection. The model would just notify the view that loading has been triggered. The view creates the progress bar delegate and informes the worker about the pointer, who keeps it in a QPointer to know whether it is still around.

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            1

            • Login

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