Adding items into List Widget
Although you can add items to the List Widget item manually through Property Editor, sometimes you need to add items to the List Widget item dynamically through code. Let's create an application that explains the process of adding items to List Widget.
In this application, you will use Label, Line Edit, Push Button, and List Widget. The List Widget item will be empty initially, and the user is asked to enter desired food items into Line Edit and select an Add to List button. The entered food item will then be added to the List Widget item. All subsequent food items will be added below the previous entry.
How to do it...
Perform the following steps to know how items can be added to the List Widget item:
- We will begin by creating a new application based on the
Dialog without Buttonstemplate and dragging and droppingLabel,Line Edit,Push Button, andList Widgetonto the form. - Set the
textproperty of theLabelandPush Buttonwidgets toYour favourite food itemand...