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 Buttons template and dragging and dropping Label, Line Edit, Push Button, and List Widget onto the form.
- Set the text property of the Label and Push Button widgets to Your favourite food item and Add to List, respectively.
- Set the objectName property of the Line Edit widget to lineEditFoodItem, that of Push Button to pushButtonAdd, and that of List Widget to listWidgetSelectedItems.
- Save the application with the name demoListWidget3.ui. The form will appear as shown in the following screenshot:
On executing the pyuic5 utility, the XML file demoListWidget3.ui will be ...