Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QComboBox

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QComboBox

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

Direct Known Subclasses:
  QFontComboBox

    public class QComboBox

extends QWidget

The `QComboBox` widget is a combined button and popup list. A `QComboBox` provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space.

A combobox is a selection widget that displays the current item, and can pop up a list of selectable items. A combobox may be editable, allowing the user to modify each item in the list.

Comboboxes can contain pixmaps as well as strings; the `insertItem()` and `setItemText()` functions are suitably overloaded. For editable comboboxes, the function `clearEditText()` is provided, to clear the displayed string without changing the combobox's contents.

There are two signals emitted if the current item of a combobox changes, `currentIndexChanged()` and `activated()` . `currentIndexChanged()` is always emitted regardless if the change was done programmatically or by user interaction, while `activated()` is only emitted when the change is caused by user interaction. The `highlighted()` signal is emitted when the user highlights an item in the combobox popup list. All three signals exist in two versions, one with a QString argument and one with an `int` argument. If the user selectes or highlights a pixmap, only the `int` signals are emitted. Whenever the text of an editable combobox is changed the `editTextChanged()` signal is emitted.

When the user enters a new string in an editable combobox, the widget may or may not insert it, and it can insert it in several locations. The default policy is is `AtBottom` but you can change this using `setInsertPolicy()`.

It is possible to constrain the input to an editable combobox using `QValidator`; see `setValidator()`. By default, any input is accepted.

A combobox can be populated using the insert functions, `insertItem()` and `insertItems()` for example. Items can be changed with `setItemText()`. An item can be removed with `removeItem()` and all items can be removed with `clear()`. The text of the current item is returned by `currentText()`, and the text of a numbered item is returned with text(). The current item can be set with `setCurrentIndex()`. The number of items in the combobox is returned by `count()`; the maximum number of items can be set with `setMaxCount()`. You can allow editing using `setEditable()`. For editable comboboxes you can set auto-completion using `setCompleter()` and whether or not the user can add duplicates is set with `setDuplicatesEnabled()`.

`QComboBox` uses the model/view framework for its popup list and to store its items. By default a `QStandardItemModel` stores the items and a `QListView` subclass displays the popuplist. You can access the model and view directly (with `model()` and `view()`), but `QComboBox` also provides functions to set and get item data (e.g., `setItemData()` and `itemText()`). You can also set a new model and view (with `setModel()` and `setView()`). For the text and icon in the combobox label, the data in the model that has the `Qt::DisplayRole` and `Qt::DecorationRole` is used.

See also:
  `QLineEdit`, `QSpinBox`, `QRadioButton`, `QButtonGroup`, and GUI Design Handbook: Combo Box, Drop-Down List Box.

Nested Class Summary
`static class` | `QComboBox.InsertPolicy` This enum specifies what the `QComboBox` should do when a new string is entered by the user.
`static class` | `QComboBox.SizeAdjustPolicy` This enum specifies how the size hint of the `QComboBox` should adjust when new content is added or content changes.

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal1` | `activated` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `activatedIndex` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `currentIndexChanged` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `currentStringChanged` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `editTextChanged` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `highlighted` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `highlightedIndex` This signal takes 1 generic argument(s).

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QComboBox()` Constructs a combobox with the given `parent`, using the default model `QStandardItemModel`.
`QComboBox(QWidget parent)` Constructs a combobox with the given `parent`, using the default model `QStandardItemModel`.

Method Summary
`void` | `addItem(QIcon icon, java.lang.String text)` Adds an item to the combobox with the given `icon` and `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ).
`void` | `addItem(QIcon icon, java.lang.String text, java.lang.Object userData)` Adds an item to the combobox with the given `icon` and `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ).
`void` | `addItem(java.lang.String text)` Adds an item to the combobox with the given `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ).
`void` | `addItem(java.lang.String text, java.lang.Object userData)` Adds an item to the combobox with the given `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ).
`void` | `addItems(java.util.List texts)` Adds each of the strings in the given `texts` to the combobox.
`void` | `clear()` Clears the combobox, removing all items.
`void` | `clearEditText()` Clears the contents of the line edit used for editing in the combobox.
`QCompleter` | `completer()` Returns the completer that is used to auto complete text input for the combobox.
`int` | `count()` This property holds the number of items in the combobox.
`int` | `currentIndex()` This property holds the index of the current item in the combobox.
`java.lang.String` | `currentText()` This property holds the text of the current item.
`boolean` | `duplicatesEnabled()` This property holds whether the user can enter duplicate items into the combobox.
`int` | `findData(java.lang.Object data)` Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.
`int` | `findData(java.lang.Object data, int role)` Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.
`int` | `findData(java.lang.Object data, int role, Qt.MatchFlag[] flags)` Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.
`int` | `findData(java.lang.Object data, int role, Qt.MatchFlags flags)` Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.
`int` | `findText(java.lang.String text)` Returns the index of the item containing the given `text`; otherwise returns -1.
`int` | `findText(java.lang.String text, Qt.MatchFlag[] flags)` Returns the index of the item containing the given `text`; otherwise returns -1.
`int` | `findText(java.lang.String text, Qt.MatchFlags flags)` Returns the index of the item containing the given `text`; otherwise returns -1.
`boolean` | `hasFrame()` This property holds whether the combo box draws itself with a frame.
`void` | `hidePopup()` Hides the list of items in the combobox if it is currently visible; otherwise this function does nothing.
`QSize` | `iconSize()` This property holds the size of the icons shown in the combobox.
`protected void` | `initStyleOption(QStyleOptionComboBox option)` Initialize `option` with the values from this QComboBox.
`void` | `insertItem(int index, QIcon icon, java.lang.String text)` Inserts the `icon`, `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.
`void` | `insertItem(int index, QIcon icon, java.lang.String text, java.lang.Object userData)` Inserts the `icon`, `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.
`void` | `insertItem(int index, java.lang.String text)` Inserts the `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.
`void` | `insertItem(int index, java.lang.String text, java.lang.Object userData)` Inserts the `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.
`void` | `insertItems(int index, java.util.List texts)` Inserts the strings from the `list` into the combobox as separate items, starting at the `index` specified.
`QComboBox.InsertPolicy` | `insertPolicy()` This property holds the policy used to determine where user-inserted items should appear in the combobox.
`void` | `insertSeparator(int index)` Inserts a separator item into the combobox at the given `index`.
`boolean` | `isEditable()` This property holds whether the combo box can be edited by the user.
`java.lang.Object` | `itemData(int index)` Returns the data for the given `role` in the given `index` in the combobox, or `QVariant::Invalid` if there is no data for this role.
`java.lang.Object` | `itemData(int index, int role)` Returns the data for the given `role` in the given `index` in the combobox, or `QVariant::Invalid` if there is no data for this role.
`QAbstractItemDelegate` | `itemDelegate()` Returns the item delegate used by the popup list view.
`QIcon` | `itemIcon(int index)` Returns the icon for the given `index` in the combobox.
`java.lang.String` | `itemText(int index)` Returns the text for the given `index` in the combobox.
`QLineEdit` | `lineEdit()` Returns the line edit used to edit items in the combobox, or 0 if there is no line edit.
`int` | `maxCount()` This property holds the maximum number of items allowed in the combobox.
`int` | `maxVisibleItems()` This property holds the maximum allowed size on screen of the combo box, measured in items.
`int` | `minimumContentsLength()` This property holds the minimum number of characters that should fit into the combobox.
`QAbstractItemModel` | `model()` Returns the model used by the combobox.
`int` | `modelColumn()` This property holds the column in the model that is visible.
`void` | `removeItem(int index)` Removes the item at the given `index` from the combobox.
`com.trolltech.qt.core.QModelIndex` | `rootModelIndex()` Returns the root model item index for the items in the combobox.
`void` | `setCompleter(QCompleter c)` Sets the `completer` to use instead of the current completer.
`void` | `setCurrentIndex(int index)` This property holds the index of the current item in the combobox.
`void` | `setDuplicatesEnabled(boolean enable)` This property holds whether the user can enter duplicate items into the combobox.
`void` | `setEditable(boolean editable)` This property holds whether the combo box can be edited by the user.
`void` | `setEditText(java.lang.String text)` Sets the `text` in the combobox's text edit.
`void` | `setFrame(boolean arg__1)` This property holds whether the combo box draws itself with a frame.
`void` | `setIconSize(QSize size)` This property holds the size of the icons shown in the combobox.
`void` | `setInsertPolicy(QComboBox.InsertPolicy policy)` This property holds the policy used to determine where user-inserted items should appear in the combobox.
`void` | `setItemData(int index, java.lang.Object value)` Sets the data `role` for the item on the given `index` in the combobox to the specified `value`.
`void` | `setItemData(int index, java.lang.Object value, int role)` Sets the data `role` for the item on the given `index` in the combobox to the specified `value`.
`void` | `setItemDelegate(QAbstractItemDelegate delegate)` Sets the item `delegate` for the popup list view.
`void` | `setItemIcon(int index, QIcon icon)` Sets the `icon` for the item on the given `index` in the combobox.
`void` | `setItemText(int index, java.lang.String text)` Sets the `text` for the item on the given `index` in the combobox.
`void` | `setLineEdit(QLineEdit edit)` Sets the line `edit` to use instead of the current line edit widget.
`void` | `setMaxCount(int max)` This property holds the maximum number of items allowed in the combobox.
`void` | `setMaxVisibleItems(int maxItems)` This property holds the maximum allowed size on screen of the combo box, measured in items.
`void` | `setMinimumContentsLength(int characters)` This property holds the minimum number of characters that should fit into the combobox.
`void` | `setModel(QAbstractItemModel model)` Sets the model to be `model`.
`void` | `setModelColumn(int visibleColumn)` This property holds the column in the model that is visible.
`void` | `setRootModelIndex(com.trolltech.qt.core.QModelIndex index)` Sets the root model item `index` for the items in the combobox.
`void` | `setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy policy)` This property holds the policy describing how the size of the combobox changes when the content changes.
`void` | `setValidator(QValidator v)` Sets the `validator` to use instead of the current validator.
`void` | `setView(QAbstractItemView itemView)` Sets the view to be used in the combobox popup to the given `itemView`.
`void` | `showPopup()` Displays the list of items in the combobox.
`QComboBox.SizeAdjustPolicy` | `sizeAdjustPolicy()` This property holds the policy describing how the size of the combobox changes when the content changes.
`QValidator` | `validator()` Returns the validator that is used to constrain text input for the combobox.
`QAbstractItemView` | `view()` Returns the list view used for the combobox popup.

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### activated

    public final QSignalEmitter.Signal1 activated

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: index)>:

  This signal is sent when the user chooses an item in the combobox. The item's `index` is passed. Note that this signal is sent even when the choice is not changed. If you need to know when the choice actually changes, use signal `currentIndexChanged()` .

### activatedIndex

    public final QSignalEmitter.Signal1 activatedIndex

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: index)>:

  This signal is sent when the user chooses an item in the combobox. The item's `index` is passed. Note that this signal is sent even when the choice is not changed. If you need to know when the choice actually changes, use signal `currentIndexChanged()` .

### currentStringChanged

    public final QSignalEmitter.Signal1 currentStringChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: arg__1)>:

### currentIndexChanged

    public final QSignalEmitter.Signal1 currentIndexChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: index)>:

  This signal is sent whenever the `currentIndex` in the combobox changes either through user interaction or programmatically. The item's `index` is passed or -1 if the combobox becomes empty or the `currentIndex` was reset.

### editTextChanged

    public final QSignalEmitter.Signal1 editTextChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: text)>:

  This signal is emitted when the text in the combobox's line edit widget is changed. The new text is specified by `text`.

### highlighted

    public final QSignalEmitter.Signal1 highlighted

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: index)>:

  This signal is sent when an item in the combobox popup list is highlighted by the user. The item's `index` is passed.

### highlightedIndex

    public final QSignalEmitter.Signal1 highlightedIndex

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: index)>:

  This signal is sent when an item in the combobox popup list is highlighted by the user. The item's `index` is passed.

Constructor Detail

### QComboBox

    public QComboBox()

  Constructs a combobox with the given `parent`, using the default model `QStandardItemModel`.

### QComboBox

    public QComboBox(QWidget parent)

  Constructs a combobox with the given `parent`, using the default model `QStandardItemModel`.

Method Detail

### addItem

    public final void addItem(QIcon icon,
                              java.lang.String text)

  Adds an item to the combobox with the given `icon` and `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ). The item is appended to the list of existing items.

### addItem

    public final void addItem(QIcon icon,
                              java.lang.String text,
                              java.lang.Object userData)

  Adds an item to the combobox with the given `icon` and `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ). The item is appended to the list of existing items.

### addItem

    public final void addItem(java.lang.String text)

  Adds an item to the combobox with the given `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ). The item is appended to the list of existing items.

### addItem

    public final void addItem(java.lang.String text,
                              java.lang.Object userData)

  Adds an item to the combobox with the given `text`, and containing the specified `userData` (stored in the `Qt::UserRole` ). The item is appended to the list of existing items.

### addItems

    public final void addItems(java.util.List texts)

  Adds each of the strings in the given `texts` to the combobox. Each item is appended to the list of existing items in turn.

### clear

    public final void clear()

  Clears the combobox, removing all items.

  Note: If you have set an external model on the combobox this model will still be cleared when calling this function.

### clearEditText

    public final void clearEditText()

  Clears the contents of the line edit used for editing in the combobox.

### completer

    public final QCompleter completer()

  Returns the completer that is used to auto complete text input for the combobox.

See also:
  `setCompleter()`, and `editable`.

### count

    public final int count()

  This property holds the number of items in the combobox. By default, for an empty combo box, this property has a value of 0.

### currentIndex

    public final int currentIndex()

  This property holds the index of the current item in the combobox. The current index can change when inserting or removing items.

  By default, for an empty combo box or a combo box in which no current item is set, this property has a value of -1.

### currentText

    public final java.lang.String currentText()

  This property holds the text of the current item. By default, for an empty combo box or a combo box in which no current item is set, this property contains an empty string.

### duplicatesEnabled

    public final boolean duplicatesEnabled()

  This property holds whether the user can enter duplicate items into the combobox. Note that it is always possible to programmatically insert duplicate items into the combobox.

  By default, this property is false (duplicates are not allowed).

### findData

    public final int findData(java.lang.Object data,
                              int role,
                              Qt.MatchFlag[] flags)

  Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findData

    public final int findData(java.lang.Object data,
                              int role)

  Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findData

    public final int findData(java.lang.Object data)

  Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findData

    public final int findData(java.lang.Object data,
                              int role,
                              Qt.MatchFlags flags)

  Returns the index of the item containing the given `data` for the given `role`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findText

    public final int findText(java.lang.String text,
                              Qt.MatchFlag[] flags)

  Returns the index of the item containing the given `text`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findText

    public final int findText(java.lang.String text)

  Returns the index of the item containing the given `text`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### findText

    public final int findText(java.lang.String text,
                              Qt.MatchFlags flags)

  Returns the index of the item containing the given `text`; otherwise returns -1.

  The `flags` specify how the items in the combobox are searched.

### hasFrame

    public final boolean hasFrame()

  This property holds whether the combo box draws itself with a frame. If enabled (the default) the combo box draws itself inside a frame, otherwise the combo box draws itself without any frame.

### iconSize

    public final QSize iconSize()

  This property holds the size of the icons shown in the combobox. Unless explicitly set this returns the default value of the current style. This size is the maximum size that icons can have; icons of smaller size are not scaled up.

### insertItem

    public final void insertItem(int index,
                                 QIcon icon,
                                 java.lang.String text)

  Inserts the `icon`, `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.

  If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
  `insertItems()`.

### insertItem

    public final void insertItem(int index,
                                 QIcon icon,
                                 java.lang.String text,
                                 java.lang.Object userData)

  Inserts the `icon`, `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.

  If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
  `insertItems()`.

### insertItem

    public final void insertItem(int index,
                                 java.lang.String text)

  Inserts the `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.

  If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
  `insertItems()`.

### insertItem

    public final void insertItem(int index,
                                 java.lang.String text,
                                 java.lang.Object userData)

  Inserts the `text` and `userData` (stored in the `Qt::UserRole` ) into the combobox at the given `index`.

  If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
  `insertItems()`.

### insertItems

    public final void insertItems(int index,
                                  java.util.List texts)

  Inserts the strings from the `list` into the combobox as separate items, starting at the `index` specified.

  If the index is equal to or higher than the total number of items, the new items are appended to the list of existing items. If the index is zero or negative, the new items are prepended to the list of existing items.

See also:
  `insertItem()`.

### insertPolicy

    public final QComboBox.InsertPolicy insertPolicy()

  This property holds the policy used to determine where user-inserted items should appear in the combobox. The default value is `AtBottom` , indicating that new items will appear at the bottom of the list of items.

See also:
  `InsertPolicy` .

### insertSeparator

    public final void insertSeparator(int index)

  Inserts a separator item into the combobox at the given `index`.

  If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
  `insertItem()`.

### isEditable

    public final boolean isEditable()

  This property holds whether the combo box can be edited by the user. By default, this property is false.

### itemData

    public final java.lang.Object itemData(int index)

  Returns the data for the given `role` in the given `index` in the combobox, or `QVariant::Invalid` if there is no data for this role.

See also:
  `setItemData()`.

### itemData

    public final java.lang.Object itemData(int index,
                                           int role)

  Returns the data for the given `role` in the given `index` in the combobox, or `QVariant::Invalid` if there is no data for this role.

See also:
  `setItemData()`.

### itemDelegate

    public final QAbstractItemDelegate itemDelegate()

  Returns the item delegate used by the popup list view.

See also:
  `setItemDelegate()`.

### itemIcon

    public final QIcon itemIcon(int index)

  Returns the icon for the given `index` in the combobox.

See also:
  `setItemIcon()`.

### itemText

    public final java.lang.String itemText(int index)

  Returns the text for the given `index` in the combobox.

See also:
  `setItemText()`.

### lineEdit

    public final QLineEdit lineEdit()

  Returns the line edit used to edit items in the combobox, or 0 if there is no line edit.

  Only editable combo boxes have a line edit.

See also:
  `setLineEdit()`.

### maxCount

    public final int maxCount()

  This property holds the maximum number of items allowed in the combobox. Note: If you set the maximum number to be less then the current amount of items in the combobox, the extra items will be truncated. This also applies if you have set an external model on the combobox.

  By default, this property's value is derived from the highest signed integer available (typically 2147483647).

### maxVisibleItems

    public final int maxVisibleItems()

  This property holds the maximum allowed size on screen of the combo box, measured in items. By default, this property has a value of 10.

  Note: This property is ignored for non-editable comboboxes in Mac style.

### minimumContentsLength

    public final int minimumContentsLength()

  This property holds the minimum number of characters that should fit into the combobox. The default value is 0.

  If this property is set to a positive value, the `minimumSizeHint()` and `sizeHint()` take it into account.

See also:
  `sizeAdjustPolicy`.

### model

    public final QAbstractItemModel model()

  Returns the model used by the combobox.

See also:
  `setModel()`.

### modelColumn

    public final int modelColumn()

  This property holds the column in the model that is visible. If set prior to populating the combo box, the pop-up view will not be affected and will show the first column (using this property's default value).

  By default, this property has a value of 0.

### removeItem

    public final void removeItem(int index)

  Removes the item at the given `index` from the combobox. This will update the current index if the index is removed.

### rootModelIndex

    public final com.trolltech.qt.core.QModelIndex rootModelIndex()

  Returns the root model item index for the items in the combobox.

See also:
  `setRootModelIndex()`.

### setCompleter

    public final void setCompleter(QCompleter c)

  Sets the `completer` to use instead of the current completer. If `completer` is 0, auto completion is disabled.

  By default, for an editable combo box, a `QCompleter` that performs case insensitive inline completion is automatically created.

See also:
  `completer()`.

### setCurrentIndex

    public final void setCurrentIndex(int index)

  This property holds the index of the current item in the combobox. The current index can change when inserting or removing items.

  By default, for an empty combo box or a combo box in which no current item is set, this property has a value of -1.

### setDuplicatesEnabled

    public final void setDuplicatesEnabled(boolean enable)

  This property holds whether the user can enter duplicate items into the combobox. Note that it is always possible to programmatically insert duplicate items into the combobox.

  By default, this property is false (duplicates are not allowed).

### setEditText

    public final void setEditText(java.lang.String text)

  Sets the `text` in the combobox's text edit.

### setEditable

    public final void setEditable(boolean editable)

  This property holds whether the combo box can be edited by the user. By default, this property is false.

### setFrame

    public final void setFrame(boolean arg__1)

  This property holds whether the combo box draws itself with a frame. If enabled (the default) the combo box draws itself inside a frame, otherwise the combo box draws itself without any frame.

### setIconSize

    public final void setIconSize(QSize size)

  This property holds the size of the icons shown in the combobox. Unless explicitly set this returns the default value of the current style. This size is the maximum size that icons can have; icons of smaller size are not scaled up.

### setInsertPolicy

    public final void setInsertPolicy(QComboBox.InsertPolicy policy)

  This property holds the policy used to determine where user-inserted items should appear in the combobox. The default value is `AtBottom` , indicating that new items will appear at the bottom of the list of items.

See also:
  `InsertPolicy` .

### setItemData

    public final void setItemData(int index,
                                  java.lang.Object value)

  Sets the data `role` for the item on the given `index` in the combobox to the specified `value`.

See also:
  `itemData()`.

### setItemData

    public final void setItemData(int index,
                                  java.lang.Object value,
                                  int role)

  Sets the data `role` for the item on the given `index` in the combobox to the specified `value`.

See also:
  `itemData()`.

### setItemDelegate

    public final void setItemDelegate(QAbstractItemDelegate delegate)

  Sets the item `delegate` for the popup list view. The combobox takes ownership of the delegate.

  Warning: You should not share the same instance of a delegate between comboboxes, widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the `closeEditor()` signal, and attempt to access, modify or close an editor that has already been closed.

See also:
  `itemDelegate()`.

### setItemIcon

    public final void setItemIcon(int index,
                                  QIcon icon)

  Sets the `icon` for the item on the given `index` in the combobox.

See also:
  `itemIcon()`.

### setItemText

    public final void setItemText(int index,
                                  java.lang.String text)

  Sets the `text` for the item on the given `index` in the combobox.

See also:
  `itemText()`.

### setLineEdit

    public final void setLineEdit(QLineEdit edit)

  Sets the line `edit` to use instead of the current line edit widget.

  The combo box takes ownership of the line edit.

See also:
  `lineEdit()`.

### setMaxCount

    public final void setMaxCount(int max)

  This property holds the maximum number of items allowed in the combobox. Note: If you set the maximum number to be less then the current amount of items in the combobox, the extra items will be truncated. This also applies if you have set an external model on the combobox.

  By default, this property's value is derived from the highest signed integer available (typically 2147483647).

### setMaxVisibleItems

    public final void setMaxVisibleItems(int maxItems)

  This property holds the maximum allowed size on screen of the combo box, measured in items. By default, this property has a value of 10.

  Note: This property is ignored for non-editable comboboxes in Mac style.

### setMinimumContentsLength

    public final void setMinimumContentsLength(int characters)

  This property holds the minimum number of characters that should fit into the combobox. The default value is 0.

  If this property is set to a positive value, the `minimumSizeHint()` and `sizeHint()` take it into account.

See also:
  `sizeAdjustPolicy`.

### setModel

    public final void setModel(QAbstractItemModel model)

  Sets the model to be `model`. `model` must not be 0. If you want to clear the contents of a model, call `clear()`.

See also:
  `model()`, and `clear()`.

### setModelColumn

    public final void setModelColumn(int visibleColumn)

  This property holds the column in the model that is visible. If set prior to populating the combo box, the pop-up view will not be affected and will show the first column (using this property's default value).

  By default, this property has a value of 0.

### setRootModelIndex

    public final void setRootModelIndex(com.trolltech.qt.core.QModelIndex index)

  Sets the root model item `index` for the items in the combobox.

See also:
  `rootModelIndex()`.

### setSizeAdjustPolicy

    public final void setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy policy)

  This property holds the policy describing how the size of the combobox changes when the content changes. The default value is `AdjustToContentsOnFirstShow` .

See also:
  `SizeAdjustPolicy` .

### setValidator

    public final void setValidator(QValidator v)

  Sets the `validator` to use instead of the current validator.

See also:
  `validator()`.

### setView

    public final void setView(QAbstractItemView itemView)

  Sets the view to be used in the combobox popup to the given `itemView`. The combobox takes ownership of the view.

  Note: If you want to use the convenience views (like `QListWidget`, `QTableWidget` or `QTreeWidget`), make sure to call `setModel()` on the combobox with the convenience widgets model before calling this function.

See also:
  `view()`.

### sizeAdjustPolicy

    public final QComboBox.SizeAdjustPolicy sizeAdjustPolicy()

  This property holds the policy describing how the size of the combobox changes when the content changes. The default value is `AdjustToContentsOnFirstShow` .

See also:
  `SizeAdjustPolicy` .

### validator

    public final QValidator validator()

  Returns the validator that is used to constrain text input for the combobox.

See also:
  `setValidator()`, and `editable`.

### view

    public final QAbstractItemView view()

  Returns the list view used for the combobox popup.

See also:
  `setView()`.

### hidePopup

    public void hidePopup()

  Hides the list of items in the combobox if it is currently visible; otherwise this function does nothing.

### showPopup

    public void showPopup()

  Displays the list of items in the combobox. If the list is empty then the no items will be shown.

### initStyleOption

    protected final void initStyleOption(QStyleOptionComboBox option)

  Initialize `option` with the values from this QComboBox. This method is useful for subclasses when they need a QStyleOptionComboBox, but don't want to fill in all the information themselves.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD