Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{alias:qcombobox}
h2. Name

*qcombobox* — collapsable text entry box

h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}

*qcombobox* \[_cmds_ ...]

{panel}

h2. Description

The *qcombobox* command creates a QComboBox object. This is a vertical list of items collapsed to a single item visible in an entry field. The entry field may be read-only. The user may expand the list by clicking on the expand-arrow at the combo's right. The user may assign one or more callback commands that are executed when a selection is made. 

To add items to the combo, use the [qinsertitem] command. To set the contents of the text field directly use [qsetitemtext]. 


h2. Arguments
_cmds_
{indent} 
One or more commands that are executed when the user selects an item in the combo. The item itself is appended to the list of commands before execution. It is the programmers responsibility to ensure that the resulting command is a valid Tcl command. 

{indent} 

h2. Examples

h3. Ex.1: QComboBox
{anchor:QComboBox}

{noformat:|borderWidth=1|bgColor=#eeeeee}
# Callback for combo.
# The argument v is added by QTcl
proc show_value { v } {
	qinformation "Combo value " $v
}

set w [qwidget]
qsetwindowtitle QComboBox
qvboxlayout {
	# Combo 1
	qcombobox
	qadditem Red
	qadditem Green
	qadditem Blue

	# Combo with callback
	qcombobox show_value
	qadditems { Top Center Bottom }

}
qshow $w

{noformat}

!att:_img_cmd^qcombobox.png!

Example [#QComboBox]+QComboBox+ shows two QComboBoxes, one having attached the callback procedure 'show_value'. The values 'Top', 'Center', or 'Bottom' will be appended to the callback string, thus forming a call to 'show_value' with an argument. The resulting command will display the chosen value in a message box.