在QML SwipeView文档中,它列出了SwipeView子级的一些附加属性。例如
SwipeView.index : int 此附加属性保存SwipeView中每个子项的索引。 它被附加到SwipeView的每个子项上。
从SwipeView子节点,如何访问这些属性?我注意到普通的SwipeView属性不引用SwipeView.,例如vertical
最后,我希望通过提供子级的附加索引属性来更改SwipeView的当前项,例如
SwipeView {
id: view
currentIndex: aBool ? firstPage.index : secondPage.index
anchors.fill: parent
Item {
id: firstPage
}
Item {
id: secondPage
}
Item {
id: thirdPage
}
}发布于 2020-04-07 04:17:00
若要从SwipeView子节点访问附加属性,需要在附加的丙基之前提供SwipeView.。
因此,我上面的例子是
SwipeView {
id: view
currentIndex: aBool ? firstPage.SwipeView.index : secondPage.SwipeView.index
anchors.fill: parent
Item {
id: firstPage
}
Item {
id: secondPage
}
Item {
id: thirdPage
}
}https://stackoverflow.com/questions/61072581
复制相似问题