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. Skip animation if its target is null
Forum Updated to NodeBB v4.3 + New Features

Skip animation if its target is null

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 370 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    Qt 6.2.0, I have this animation:

    SequentialAnimation {
        id: selectedContent
        running: false
    
        ParallelAnimation {
            PropertyAnimation { target: view; properties: "opacity"; duration: 500; to: 0.0}
            PropertyAnimation { target: view.currentItem; properties: "y"; duration: 500; to: view.height * 2}
        }
    
        ScriptAction { script: flow.selectedContent(view.currentIndex) }
    
        ParallelAnimation {
            PropertyAnimation { target: view; properties: "opacity"; duration: 500; to: 1.0}
            PropertyAnimation { target: view.currentItem; properties: "y"; duration: 500; to: view.height / 2}
        }
    }
    

    It may happen that view.currentItem is null. When it happens the application crashes.
    How can I skip a ParallelAnimation animation its target is null?
    I tried to put an if clause inside but it's not a valid syntax.

    I cannot just skip the whole SequentialAnimation because the execution of the script can change the view.currentItem. That means it should, say, skip the first ParallelAnimation (due to view.currentItem === null) but not the second one (as the script has changed it and now it's not null anymore).

    1 Reply Last reply
    1
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Could you share a bit more about what you want to do to give more context? We might find another solution to your problem.
      Also what is view? a StackView, a ListView, a Container?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        view is a PathView:

        PathView {
            id: view
            property int item_gap: 60
            property bool isSEM
        
            anchors.fill: parent
            pathItemCount: 3
            preferredHighlightBegin: 0.5
            preferredHighlightEnd: 0.5
            highlightRangeMode: PathView.StrictlyEnforceRange
            highlightMoveDuration: 1000
            snapMode: PathView.SnapToItem
            rotation: -90
        
            model: modelContent
            delegate: DelegateContent { }
        
            path: Path {
                startX: view.width + item_gap; startY: view.height / 2
                PathAttribute { name: "iconScale"; value: 0.7 }
                PathAttribute { name: "iconOpacity"; value: 0.1 }
                PathAttribute { name: "iconOrder"; value: 0 }
                PathLine {x: view.width / 2; y: view.height / 2; }
                PathAttribute { name: "iconScale"; value: 1 }
                PathAttribute { name: "iconOpacity"; value: 1 }
                PathAttribute { name: "iconOrder"; value: 9 }
                PathLine {x: -item_gap; y: view.height / 2; }
            }
            ...
        

        It may happen that the model has zero elements, so there is no currentItem (null). The script will populate the model so the second part of the animation should run anyway. For this reason I asked how to skip (or just avoid a crash!) if the target of an animation is null.

        1 Reply Last reply
        0
        • KH-219DesignK Offline
          KH-219DesignK Offline
          KH-219Design
          wrote on last edited by
          #4

          Does 'crash' in your case refer to a segfault? A total abrupt abnormal termination, such as the kind resulting in a dump?

          If so, can you capture and post the backtrace/callstack of the crash?

          Can you share a minimum reproducible sample project? (Maybe even a pure QML mini-app that could be launched with qmlscene and bypass the need to compile anything?)

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          M 1 Reply Last reply
          0
          • KH-219DesignK KH-219Design

            Does 'crash' in your case refer to a segfault? A total abrupt abnormal termination, such as the kind resulting in a dump?

            If so, can you capture and post the backtrace/callstack of the crash?

            Can you share a minimum reproducible sample project? (Maybe even a pure QML mini-app that could be launched with qmlscene and bypass the need to compile anything?)

            M Offline
            M Offline
            Mark81
            wrote on last edited by
            #5

            @KH-219Design yes, it's a segmentation fault.
            Would you please tell me how to capture the backtrace/callstack? When debugging I can see only a lot of disassembled code, but no one function (in any thread) is my code.

            I can prepare a sample project for you. In the meanwhile, can we generalize a bit the question?

            How to skip a step in a SequentialAnimation if some conditions are met?

            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