Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

[Prev: Customizing and Integrating Qt Designer] [Home] [Next: The Key Bindings]

Using Qt Designer's Value Editors

Qt Designer provides value editors for some widgets which allow you to set default values for particular instances. In this chapter we'll explain how to use the value editors. All value editors are invoked using the same techniques: either double click the widget or right click the widget and click the Edit menu item on the pop up menu. If you click Apply in any of the value editor dialogs the settings are applied to the widget in the form. If you want to revert your changes you can either change the settings in the value editor dialog and re-Apply, or, close the dialog and click the Undo toolbar button (or press Ctrl+Z). If you undo too much you can always click Redo (or press Ctrl+Y). First we'll briefly describe the Edit Image Collection dialog since this is used by some of the value editors.

Shared Pixmaps

Edit Image Collection Dialog

The first version of Qt Designer kept static pixmaps (icons) in each form's .cpp file. This was inefficient if the same pixmaps were required in several different forms. Qt Designer now creates a file, in which it places a single copy of each pixmap used in the application.

To add pixmaps to the application click Edit|Pixmap Collection to invoke the Edit Image Collection dialog. Any pixmaps already in the project are shown in the icon view. You can add additional pixmaps by clicking Add which will pop up a file dialog through which you can choose a pixmap.

If you create a widget which has an iconSet or pixmap property you can click the ellipsis button to invoke the Edit Image Collection dialog through which you can select a pixmap for the widget. The ellipsis button appears when you click in the Value part of the Properties list by a pixmap or iconSet property. Some widgets can hold multiple pixmaps, for example a list box can hold both pixmaps and text. The list box's value editor can be used to add pixmaps as required. (This is described in ListBox and ComboBox.)

If you really want to store pixmaps in a particular form rather than in the images file you can do so: right click the form, then click Form Settings; click 'Save Inline', then click OK.

ListBox and ComboBox

Edit List Box Dialog

This value editor allows us to hard-code list items in ComboBoxes and List Boxes. We can always change them at runtime. A list item consists of some text or a pixmap or both. Items are added by clicking the New Item button and deleted by clicking Delete Item. The order of items can be changed by clicking an item in the list to select it and clicking the up and down blue arrows to move the selected item. If you want a pixmap click the ellipsis button which will pop up the Edit Image Collection dialog. You can either choose one of the pixmaps shown or click Add to add one from somewhere in your filesystem. To remove a pixmap click the item, then click the scissors button. The same value editor is used for list boxes and combo boxes.

ListView (Tree View)

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 Image 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.

TextEdit

Text Dialog

This widget is a multi-line editor (superseding QMultiLineEdit), which can display either plain text or rich text. The dialog presents a text edit in plain text mode. You can enter rich text by using HTML tags and attributes, for example,

<h2>Text Edit</h2>
<p align="center">
The Text Edit widget supports <b>rich</b>
<font color="ff0000">text</font>.</p>

Block level tags like headings, aligned paragraphs, ordered and unordered lists are all available. Inline tags like bold, italic, big, small and font are also supported. Tables, hypertext links and images may also be used. Full information on the tags and attributes that Text Edit supports is given in the online QStyleSheet documentation.

Table

Edit Table Dialog

This dialog is used to set up the characteristics of a Table; it is not a value editor. The Edit Table dialog is used to specify how many columns and rows the table should have and to label the rows and columns. All these characteristics can be changed in code. The left hand part of the dialog shows a preview of the table, the right hand part contains two tabs, the Columns tab and the Rows tab. Columns are added by clicking the New Column button. A column may have a textual label entered in the Label line edit and a pixmap. The pixmap is inserted by clicking the ellipsis button and choosing the pixmap you want. You can delete the pixmap by clicking the scissors button. The columns can be reordered by clicking a column in the column list and then clicking the blue up and down arrow buttons. To delete a column click it in the column list then click Delete Column.

The Rows tab is used to add rows. It works in the same way as the columns tab. Click New Row to add a row and change its label in the Label line edit. Rows can also have a pixmap and may be reordered in exactly the same way as columns. The contents of cells must be inserted through code.

IconView

Edit Iconview Dialog

This dialog is used to add icons with text labels to an IconView. New items are added by clicking New Item, then typing in their text in the Text line edit. Items can also be added or deleted in code. You can either use the default icon or choose your own by clicking the ellipsis button to invoke the Edit Image Collection dialog. The pixmap can be deleted by clicking the scissors button, and the item can be deleted by clicking it then clicking Delete Item.

[Prev: Customizing and Integrating Qt Designer] [Home] [Next: The Key Bindings]


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta4