[SOLVED]StackViewDelegate getTransition



  • Hello,

    i would like to use a property from the StackView in the StackViewDelegate function getTransition.
    Here is a sample code:
    @
    StackView {
    id: pageStack
    anchors.fill: parent

        property string transitionType: "Goto"
    
        delegate: StackViewDelegate {
            function getTransition(properties)
            {
                switch(transitionType) {
                    case "Up": return upTransition
                    case "Down": return downTransition
                    default: return gotoTransition
                }
            }
     ...
    

    @

    In the above code the variable transitionType in Line 10 is not defined. The idea is to change the transition type from extern.
    How can i do this?

    Thanks



  • The property string transitionType is defined in it's parent, so just access it that way:
    @ function getTransition(properties)
    {
    switch(parent.transitionType) {
    case "Up": return upTransition
    case "Down": return downTransition
    default: return gotoTransition
    }
    }@

    Also it is possible to access it's id and then the property:

    @ function getTransition(properties)
    {
    switch(pageStack.transitionType) {
    case "Up": return upTransition
    case "Down": return downTransition
    default: return gotoTransition
    }
    }@



  • Thank you. That worked.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.