4.8. Combo widget class

The Combo class inherits QComboBox Qt class.

Widget's input value

The input value of the Combo widget is an XML string. The XML syntax is the same as the List widget input value.

Widget's attributes

The Combo widget accepts the same attributes as a List widget. Specific attributes are :

ro
If set to False, the user can enter a custom string into the Combo.
completion
This attribute holds the completion mode. popup (which is the default) means that current completions are displayed in a popup window. inline means that completions appear inline (as selected text). all means that all possible completions are displayed in a popup window with the most likely suggestion selected.

Widget's functions

getItemValue(item)
This function returns an item's value. item can be the id, the text or the index of the item.
getCurrentValue()
This function returns the current selected item. If the current item is a text manually entered by the user (when ro is False), the returned item's value has an id and row attributes sets to None.
getEditText()
This function returns the content of the line edit used to manually enter text in read write mode.
addItems(data='', position=-1)
This function adds items into the Combo. The arguments format is the same as the List widget addItems function.
editItem(item, data)
This function edits item. The arguments format is the same as the List widget editItem function.
editCurrentItem(data)
Edit the current item. data holds the item's elements to edit and follow the same rules as the editItem function.
delItems(items)
This function deletes items. items format is the same as the List widget delItems function.
delCurrentItem()
This function deletes the current selected items.
clear()
This function deletes all items.
select(item)
This function makes item the current selected item. item can be the id, the text or the index of the item.

Widget's signals

itemCheckChanged(item)
This signal is emitted when an item's checked state change. item is the value of item as returned with the getItemValue function.

Widget's output value

The output value of a Combo widget depends on two attributes : verbose and return.

If verbose is False and the user enters a text manually, the output value is a dict in the form : {'id':None, 'row':None, 'value':TEXT}.

If verbose is False and the user selects an item, the output value is a dict in the form : {'id':ID, 'row':INDEX, 'value':TEXT, 'checked':BOOL, 'data':DATA}.

If verbose is True and return is dict, the output value is a dict in the form : {ITEM_1_ID:ITEM_1_VALUE, ITEM_2_ID:ITEM_2_VALUE, ..., ITEM_n_ID:ITEM_n_VALUE} where ITEM_ID is the id of the item and ITEM_VALUE is a dict in the form {'value':TEXT, 'row':INDEX, 'selected':BOOL, 'checked':BOOL, 'data':DATA}.

If verbose is True and return is list, the output value is a list of items values. Each item's value is a dict in the form : {'id':ID, 'value':TEXT, 'row':INDEX, 'selected':BOOL, 'checked':BOOL, 'data':DATA}.

When verbose is True and ro is False and the user has entered a text into the line edit, an item with id set to None is added to others items values.