Adding Items to SwipeView



  • I searched the forums, but couldn't find anything about this. I'm trying to add items to a SwipeView; specifically, a rectangle. I don't get any results when I try to add the item. I have also tried adding a SwipeViewDelegate, but that has some odd behavior, and doesn't work more than once. Here is some code:

    SwipeView {
            id: swipeView
            anchors.fill: parent
            currentIndex: tabBar.currentIndex
    
            Rectangle{
                width: 640
                height: 480
                color: "red"
            }
    
            Rectangle{
                width: 640
                height: 480
                color: "green"
            }
    
            Rectangle{
                width: 640
                height: 480
                color: "blue"
            }
    
            onCountChanged: {
                console.log("Count has changed");
            }
    
        }
    
    Component{
            id: rectangleDelegate
            Rectangle{
                width: 640
                height: 480
                color: "black"
            }
        }
    
        Button{
            width: 100
            height: 50
            text: qsTr("Add Page")
            onClicked: {
                swipeView.addItem(rectangleDelegate);  //This does not work
                //swipeView.addItem(Rectangle); //This also does not work
            }
    
        }
    

    I have not included the SwipeDelegate code, as it doesn't do what I'm intending it to do anyway. The question is, how do you add items to SwipeView dynamically?

    Thanks!
    -Alex


Log in to reply
 

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