0
votes

In the QML SwipeView documentation, it lists some attached properties for SwipeView children. For example

SwipeView.index : int

This attached property holds the index of each child item in the SwipeView.

It is attached to each child item of the SwipeView.

From a SwipeView child, how do I access these properties? I have noticed the normal SwipeView properties do not reference SwipeView. for example vertical

Ultimately I want to change SwipeView's current item by providing it the child's attached index property, for example

SwipeView {
    id: view

    currentIndex: aBool ? firstPage.index : secondPage.index
    anchors.fill: parent

    Item {
        id: firstPage
    }
    Item {
        id: secondPage
    }
    Item {
        id: thirdPage
    }
}
1

1 Answers

0
votes

To access the attached properties from a SwipeView child, need to provide SwipeView. before the attached proptery.

Therefore my example above would be

SwipeView {
    id: view

    currentIndex: aBool ? firstPage.SwipeView.index : secondPage.SwipeView.index
    anchors.fill: parent

    Item {
        id: firstPage
    }
    Item {
        id: secondPage
    }
    Item {
        id: thirdPage
    }
}