Forums

OverviewFelgo 2 Support (Qt 5) › Using SwipeButton to remove SimpleRow Item

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17887

    Felgo User

    I’m trying to remove a SimpleRow Item from a model using a SwipeButton within a SwipeOptionsContainer. Assuming that all values of my model are the same (no way to differentiate each row by value, only by index), what would be the best approach?

     

     ListPage {
            id: listpage
            model: mymodel
    
            delegate: SwipeOptionsContainer {
              id: container
             
              SimpleRow {
                  id: row
              }
    
              leftOption: SwipeButton {
                icon: IconType.trash
                height: parent.height
                onClicked: {
                    //remove item, but how?               
                }
              }
            }
        }

     

     

    #17891

    Günther
    Felgo Team

    Hi!

    Within the delegate of your ListPage, you have access to the modelData variable, as well as the index.

    This means you can modify your model to remove the item you want to hide. After making changes to your model, please use

    listModel.modelChanged()

    to manually signal that the contents of your model were modified. The view will then update accordingly.

    Another possibility is to really only hide the item without modify the model, e.g. by setting the container item invisible or giving it a heigh of 0.

    Best,
    Günther

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support