Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Add a Rectangle child to a SwipeDelegate



  • I succeed in running the example on https://doc.qt.io/qt-5/qml-qtquick-controls2-swipedelegate.html
    However, I would like to add some children (eg a Rectangle) to the SwipeDelegate: when I try this

    delegate: SwipeDelegate {
                            id: swipeDelegate
                            text: model.sender + " - " + model.title
                            width: parent.width
    
                            Rectangle {
                                anchors.fill: parent
                                color: "green"
                            }
    

    I notice that:

    • the text is still swiped
    • the Rectangle isn't swiped and remains on the original location
    • the "Delete" action doesn't show up (probably still underneath the Rectangle)

    Is it somehow possible to add child-items to a SwipeDelegate?



  • This seems to work when using (note both the contentItem and the removed anchoring!)

                            contentItem: Rectangle {
                                width: parent.width
                                height: parent.height
                                color: "green"
                            }
    
    

Log in to reply