ListView (Tree View)

Edit List View

Figure 3-3. Edit List View Dialog

This editor allows us to hard-code columns and list view items in List Views. We can change the list view dynamically in code. A list view consists of one or more columns of data. The first column may have a tree structure with items having sub-items and so on. The dialog consists of two tabs, the Items tab where we can add, edit and delete items and move them within the list view, and the Columns tab where we name the columns we require.

We'll describe the Columns tab first. To add a new column click the New Column button and enter a name in the Text line edit. You can add a pixmap to the column by clicking the ellipsis button and choosing a pixmap from the Edit Pixmap Collection dialog. The scissors button is used to delete the pixmap, and the blue up and down arrow buttons are used to move the highlighted column up and down in the column list.

The Items tab is used to add items. To add a top-level item click the New Item button. To add a sub-item click the item that you want to be the sub-item's parent then click New Subitem. The Text line edit is used to enter the item's text. Since there may be more than one column the Column spin box is used to choose which column the text you enter will go into. Items can also have pixmaps which are added by clicking the ellipsis button and choosing a pixmap. They can be deleted by clicking the scissors button. Items and sub-items can be deleted by clicking them, then clicking the Delete Item button. The up and down blue arrow buttons move the selected item up and down amongst the other items with the same parent. The right and left blue arrow buttons are used to move an item up and down in the hierarchy, e.g. to make a sub-item into a top-level item click the sub-item then click the left blue arrow button.