i need to add dynamically pages on swipeview. So my code:
SwipeView {
id: viewSwipe
width: parent.width
height: parent.height * 0.70
currentIndex: 0
Component.onCompleted: {
curIndexWitouthZero = viewSwipe.currentIndex
curIndexWitouthZero += 1
addPage(RecipesPhase)
}
onCurrentIndexChanged: {
curIndexWitouthZero = viewSwipe.currentIndex
curIndexWitouthZero += 1
}
Item {
id: firstPage
RecipesPhase{}
}
}
PageIndicator {
id: indicator
interactive: true
count: viewSwipe.count
currentIndex: viewSwipe.currentIndex
anchors.top: viewSwipe.bottom
anchors.topMargin: parent.height * 0.05
anchors.horizontalCenter: parent.horizontalCenter
}
i've a button who when clicked, the event should add the pages like an Item. My code is:
MouseArea{
anchors.fill: parent
onClicked: {
console.log("Cliccato additem")
//viewSwipe.addItem(RecipesPhase)
viewSwipe.addPage(RecipesPhase)
}
}
But nothing happened. So i've tried also:
SwipeView {
id: viewSwipe
width: parent.width
height: parent.height * 0.70
currentIndex: 0
Component.onCompleted: {
curIndexWitouthZero = viewSwipe.currentIndex
curIndexWitouthZero += 1
addPage(RecipesPhase)
}
onCurrentIndexChanged: {
curIndexWitouthZero = viewSwipe.currentIndex
curIndexWitouthZero += 1
}
function addPage(page) {
console.log("funzione addPage()")
addItem(page)
page.visible = true
}
}
and then call:
viewSwipe.addPage(MyPageQML)
but nothing happened. So, the question is, where i'm wrong ? Thanks for the solutions.