O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Remove grocery item

Removing a grocery item can also be achieved in several ways: for example, long press on a delegate, swipe, and so on.

We will take a more visual way and simply add an "X" button to each delegate. Because the delegate is part of the ListItem, we will need to make any modifications through the Text Editor, as follows:

delegate: ItemDelegate {            width: parent.width            text: modelData.name || model.name            font.bold: true            Button {                width: height                height: parent.height                text: "X"                anchors.right: parent.right            }        }

From a visual point of view, we have everything that is needed to cover our first usecases. Congratulations! Of course, as we haven't tied any logic to the button and item presses, nothing will happen. Run the completed UI again ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required