Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Animations with dynamic content
QtWS25 Last Chance

Animations with dynamic content

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlquickanimationsstates
5 Posts 3 Posters 2.9k Views
  • 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.
  • D Offline
    D Offline
    dv__
    wrote on last edited by A Former User
    #1

    Hello,

    I'm new to the animations in QML, and am not sure how to integrate behaviors and animations into my use case.

    I have a list of custom QtQuick items (written in C++). I want to arrange them in a grid. The list of items is dynamic; items can be added and removed at runtime. I can also select an item, in which case it should be zoomed in.

    I want to animate the following:

    1. When I add or remove an item, the grid readjusts itself. This should be animated to show the transition between old and new arrangement. (Some ease in - ease out curve perhaps.)
    2. When I select an item, the unselected items should be pulled into the background and have their opacity set to 10%, while the selected item should be zoomed to cover the screen. So, the other items are still visible, but barely, and they are clearly in the back.

    The way I see this I'd need a Component with a bunch of states and several numerical properties in the 0..1 range: one property for linearly interpolating between an old and a new item arrangement, and one parameter for linearly interpolating between "all items 100% opaque and equally arranged" and "the N-1 unselected items at 10% opacity and moved in the back & the selected item 100% opaque and maximized in the front". Transitions between the states would then make use of Behaviors and Animation objects.

    Am I on the right path here?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I recommend checking out the built-in components first.

      To make a dynamic list of items, control them using MVP. Here is a summary of how models work in QML. Since you already have your items in C++, it might be advisable to use a C++ model based on QAbstractItemModel.

      Regarding item placement and animations, see GridView, ListView. In some cases, a Repeater could work better, or a Flow.

      And when it comes to showing single item expanded on the whole screen - maybe use StackView for that? Your grid could be on one page, and expanded views would pop in and out on demand.

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dv__
        wrote on last edited by
        #3

        Ah, good point, thanks! Using ListModel and GridView certainly makes sense. I'll check that out. Can there be a transition between the two views? I want to avoid that suddenly, the selected item is expanded - there should be a transition, where the selected item expands until it is maximized (with an ease in / ease out curve).

        Also, just out of curiosity, in a more generic case (say, some arbitrary, non-grid arrangement), would my approach make sense? I suppose I could still use ListModel in this case, but the arrangement would have to be done manually, not with an existing view.

        sierdzioS GrecKoG 2 Replies Last reply
        0
        • D dv__

          Ah, good point, thanks! Using ListModel and GridView certainly makes sense. I'll check that out. Can there be a transition between the two views? I want to avoid that suddenly, the selected item is expanded - there should be a transition, where the selected item expands until it is maximized (with an ease in / ease out curve).

          Also, just out of curiosity, in a more generic case (say, some arbitrary, non-grid arrangement), would my approach make sense? I suppose I could still use ListModel in this case, but the arrangement would have to be done manually, not with an existing view.

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @dv__ said in QML animations with dynamic content:

          Ah, good point, thanks! Using ListModel and GridView certainly makes sense. I'll check that out. Can there be a transition between the two views? I want to avoid that suddenly, the selected item is expanded - there should be a transition, where the selected item expands until it is maximized (with an ease in / ease out curve).

          Yes, see the documentation. You can animate adding, removing, moving items in a grid. And about expanding the item - here I would rather recommend creating a different component for the "big" element. Then you can animate the expansion while the base grid would actually stay unchanged.

          Also, just out of curiosity, in a more generic case (say, some arbitrary, non-grid arrangement), would my approach make sense? I suppose I could still use ListModel in this case, but the arrangement would have to be done manually, not with an existing view.

          Yes, using the models is supported by all positioners like GridView, ListView, PathView (that one allows you to position them really arbitrarily). If you want to show a view with more advanced grid (like Microsoft's tiles, for example, where they can all be of different sizes), there are external QML extensions that can help. I/m sure I've seen some here on forums, but I can't find it now :|

          (Z(:^

          1 Reply Last reply
          0
          • D dv__

            Ah, good point, thanks! Using ListModel and GridView certainly makes sense. I'll check that out. Can there be a transition between the two views? I want to avoid that suddenly, the selected item is expanded - there should be a transition, where the selected item expands until it is maximized (with an ease in / ease out curve).

            Also, just out of curiosity, in a more generic case (say, some arbitrary, non-grid arrangement), would my approach make sense? I suppose I could still use ListModel in this case, but the arrangement would have to be done manually, not with an existing view.

            GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            @dv__ said in QML animations with dynamic content:

            Also, just out of curiosity, in a more generic case (say, some arbitrary, non-grid arrangement), would my approach make sense? I suppose I could still use ListModel in this case, but the arrangement would have to be done manually, not with an existing view.

            To do this I'd use a raw Item container with a Repeater and manual positioning in the delegates.

            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