Qt Jambi Home

com.trolltech.qt.gui
Class QComboBox

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by 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.

Comboboxes in the different built-in styles.

See Also:
QLineEdit, QSpinBox, QRadioButton, QButtonGroup, 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<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<java.lang.String> activated
          This signal is sent when an item in the combobox is activated by the user.
 QSignalEmitter.Signal1<java.lang.Integer> activatedIndex
          This signal is sent when an item in the combobox is activated by the user.
 QSignalEmitter.Signal1<java.lang.Integer> currentIndexChanged
          This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically.
 QSignalEmitter.Signal1<java.lang.String> currentStringChanged
          This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically.
 QSignalEmitter.Signal1<java.lang.String> editTextChanged
          This signal is emitted when the text in the combobox's line edit widget is changed.
 QSignalEmitter.Signal1<java.lang.String> highlighted
          This signal is sent when an item in the combobox popup list is highlighted by the user.
 QSignalEmitter.Signal1<java.lang.Integer> highlightedIndex
          This signal is sent when an item in the combobox popup list is highlighted by the user.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QComboBox()
          Equivalent to QComboBox(0).
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)
          Equivalent to addItem(icon, text, QVariant()).
 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.
 void addItem(java.lang.String text)
          Equivalent to addItem(text, QVariant()).
 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.
 void addItems(java.util.List<java.lang.String> texts)
          Adds each of the strings in the given texts to the combobox.
protected  void changeEvent(QEvent e)
          This function is reimplemented for internal reasons.
 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.
protected  void contextMenuEvent(QContextMenuEvent e)
          This function is reimplemented for internal reasons.
 int count()
          Returns the number of items in the combobox.
 int currentIndex()
          Returns the index of the current item in the combobox.
 java.lang.String currentText()
          Returns the text of the current item.
 boolean duplicatesEnabled()
          Returns whether the user can enter duplicate items into the combobox.
 boolean event(QEvent event)
          This function is reimplemented for internal reasons.
 int findData(java.lang.Object data)
          Equivalent to findData(data, Qt::UserRole, Qt::MatchExactly | Qt::MatchCaseSensitive).
 int findData(java.lang.Object data, int role)
          Equivalent to findData(data, role, Qt::MatchExactly | Qt::MatchCaseSensitive).
 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)
          Equivalent to findText(text, Qt::MatchExactly | Qt::MatchCaseSensitive).
 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.
protected  void focusInEvent(QFocusEvent e)
          This function is reimplemented for internal reasons.
protected  void focusOutEvent(QFocusEvent e)
          This function is reimplemented for internal reasons.
static QComboBox fromNativePointer(QNativePointer nativePointer)
          This function returns the QComboBox instance pointed to by nativePointer
 boolean hasFrame()
          Returns whether the combo box draws itself with a frame.
protected  void hideEvent(QHideEvent e)
          This function is reimplemented for internal reasons.
 void hidePopup()
          Hides the list of items in the combobox if it is currently visible; otherwise this function does nothing.
 QSize iconSize()
          Returns the size of the icons shown in the combobox..
protected  void initStyleOption(QStyleOptionComboBox option)
          Initialize option with the values from this QComboBox.
protected  void inputMethodEvent(QInputMethodEvent arg__1)
          This function is reimplemented for internal reasons.
 java.lang.Object inputMethodQuery(Qt.InputMethodQuery arg__1)
          This function is reimplemented for internal reasons.
 void insertItem(int index, QIcon icon, java.lang.String text)
          Equivalent to insertItem(index, icon, text, QVariant()).
 void insertItem(int index, QIcon icon, java.lang.String text, java.lang.Object userData)
          Inserts the icon, text and userData into the combobox at the given index.
 void insertItem(int index, java.lang.String text)
          Equivalent to insertItem(index, text, QVariant()).
 void insertItem(int index, java.lang.String text, java.lang.Object userData)
          Inserts the text and userData into the combobox at the given index.
 void insertItems(int index, java.util.List<java.lang.String> texts)
          Inserts the strings from the texts into the combobox as separate items, starting at the index specified.
 QComboBox.InsertPolicy insertPolicy()
          Returns the policy used to determine where user-inserted items should appear in the combobox.
 boolean isEditable()
          Returns whether the combobox can be edited by the user.
 java.lang.Object itemData(int index)
          Equivalent to itemData(index, Qt::UserRole).
 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.
protected  void keyPressEvent(QKeyEvent e)
          This function is reimplemented for internal reasons.
protected  void keyReleaseEvent(QKeyEvent e)
          This function is reimplemented for internal reasons.
 QLineEdit lineEdit()
          Returns the line edit used to edit items in the combobox, or 0 if there is no line edit.
 int maxCount()
          Returns the maximum number of items allowed in the combobox.
 int maxVisibleItems()
          Returns the maximum allowed size on screen of the combobox.
 int minimumContentsLength()
          Returns the minimum number of characters that should fit into the combobox..
 QSize minimumSizeHint()
          This function is reimplemented for internal reasons.
 QAbstractItemModel model()
          Returns the model used by the combobox.
 int modelColumn()
          Returns the column in the model that is visible..
protected  void mousePressEvent(QMouseEvent e)
          This function is reimplemented for internal reasons.
protected  void mouseReleaseEvent(QMouseEvent e)
          This function is reimplemented for internal reasons.
protected  void paintEvent(QPaintEvent e)
          This function is reimplemented for internal reasons.
 void removeItem(int index)
          Removes the item at the given index from the combobox.
protected  void resizeEvent(QResizeEvent e)
          This function is reimplemented for internal reasons.
 QModelIndex rootModelIndex()
          Returns the root model item index for the items in the combobox.
 void setCompleter(QCompleter c)
          Sets the c to use instead of the current completer.
 void setCurrentIndex(int index)
          Sets the index of the current item in the combobox.
 void setDuplicatesEnabled(boolean enable)
          Sets whether the user can enter duplicate items into the combobox to enable.
 void setEditable(boolean editable)
          Sets whether the combobox can be edited by the user to editable.
 void setEditText(java.lang.String text)
          Sets the text in the combobox's text edit.
 void setFrame(boolean arg__1)
          Sets whether the combo box draws itself with a frame to arg__1.
 void setIconSize(QSize size)
          Sets the size of the icons shown in the combobox. to size.
 void setInsertPolicy(QComboBox.InsertPolicy policy)
          Sets the policy used to determine where user-inserted items should appear in the combobox to policy.
 void setItemData(int index, java.lang.Object value)
          Equivalent to setItemData(index, value, Qt::UserRole).
 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)
          Sets the maximum number of items allowed in the combobox to max.
 void setMaxVisibleItems(int maxItems)
          Sets the maximum allowed size on screen of the combobox to maxItems.
 void setMinimumContentsLength(int characters)
          Sets the minimum number of characters that should fit into the combobox. to characters.
 void setModel(QAbstractItemModel model)
          Sets the model to be model.
 void setModelColumn(int visibleColumn)
          Sets the column in the model that is visible. to visibleColumn.
 void setRootModelIndex(QModelIndex index)
          Sets the root model item index for the items in the combobox.
 void setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy policy)
          Sets the policy describing how the size of the combobox changes when the content changes to policy.
 void setValidator(QValidator v)
          Sets the v 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.
protected  void showEvent(QShowEvent e)
          This function is reimplemented for internal reasons.
 void showPopup()
          Displays the list of items in the combobox.
 QComboBox.SizeAdjustPolicy sizeAdjustPolicy()
          Returns the policy describing how the size of the combobox changes when the content changes.
 QSize sizeHint()
          This function is reimplemented for internal reasons.
 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.
protected  void wheelEvent(QWheelEvent e)
          This function is reimplemented for internal reasons.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusNextChild, focusNextPrevChild, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, inputContext, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, 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, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

activatedIndex

public final QSignalEmitter.Signal1<java.lang.Integer> activatedIndex

This signal is sent when an item in the combobox is activated by the user. The item's index is given.

Compatible Slot Signatures:
void mySlot(int index)
void mySlot()


activated

public final QSignalEmitter.Signal1<java.lang.String> activated

This signal is sent when an item in the combobox is activated by the user. The item's arg__1 is given.

Compatible Slot Signatures:
void mySlot(java.lang.String arg__1)
void mySlot()


currentIndexChanged

public final QSignalEmitter.Signal1<java.lang.Integer> currentIndexChanged

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

Compatible Slot Signatures:
void mySlot(int index)
void mySlot()


currentStringChanged

public final QSignalEmitter.Signal1<java.lang.String> currentStringChanged

This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically. The item's arg__1 is given.

Compatible Slot Signatures:
void mySlot(java.lang.String arg__1)
void mySlot()


editTextChanged

public final QSignalEmitter.Signal1<java.lang.String> editTextChanged

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

Compatible Slot Signatures:
void mySlot(java.lang.String arg__1)
void mySlot()


highlightedIndex

public final QSignalEmitter.Signal1<java.lang.Integer> highlightedIndex

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

Compatible Slot Signatures:
void mySlot(int index)
void mySlot()


highlighted

public final QSignalEmitter.Signal1<java.lang.String> highlighted

This signal is sent when an item in the combobox popup list is highlighted by the user. The item's arg__1 is given.

Compatible Slot Signatures:
void mySlot(java.lang.String arg__1)
void mySlot()

Constructor Detail

QComboBox

public QComboBox()

Equivalent to QComboBox(0).


QComboBox

public QComboBox(QWidget parent)

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

Method Detail

addItem

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

Equivalent to addItem(text, QVariant()).


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. The item is appended to the list of existing items.


addItem

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

Equivalent to addItem(icon, text, QVariant()).


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. The item is appended to the list of existing items.


addItems

public final void addItems(java.util.List<java.lang.String> 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, editable

count

public final int count()

Returns the number of items in the combobox.


currentIndex

public final int currentIndex()

Returns the index of the current item in the combobox. The index can change when inserting or removing items. Returns -1 if no current item is set or the combobox is empty..

See Also:
setCurrentIndex

currentText

public final java.lang.String currentText()

Returns the text of the current item.


duplicatesEnabled

public final boolean duplicatesEnabled()

Returns whether the user can enter duplicate items into the combobox.

Note that it is always possible to programmatically insert duplicate items into the combobox.

See Also:
setDuplicatesEnabled

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)

Equivalent to findData(data, role, Qt::MatchExactly | Qt::MatchCaseSensitive).


findData

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

Equivalent to findData(data, Qt::UserRole, Qt::MatchExactly | Qt::MatchCaseSensitive).


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)

Equivalent to findText(text, Qt::MatchExactly | Qt::MatchCaseSensitive).


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()

Returns 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()

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

See Also:
setIconSize

insertItem

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

Equivalent to insertItem(index, text, QVariant()).


insertItem

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

Inserts the text and userData 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)

Equivalent to insertItem(index, icon, text, QVariant()).


insertItem

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

Inserts the icon, text and userData 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<java.lang.String> texts)

Inserts the strings from the texts 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()

Returns 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:
setInsertPolicy, InsertPolicy

isEditable

public final boolean isEditable()

Returns whether the combobox can be edited by the user.


itemData

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

Equivalent to itemData(index, Qt::UserRole).


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()

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

See Also:
setMaxCount

maxVisibleItems

public final int maxVisibleItems()

Returns the maximum allowed size on screen of the combobox.

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

See Also:
setMaxVisibleItems

minimumContentsLength

public final int minimumContentsLength()

Returns 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:
setMinimumContentsLength, sizeAdjustPolicy

model

public final QAbstractItemModel model()

Returns the model used by the combobox.

See Also:
setModel

modelColumn

public final int modelColumn()

Returns the column in the model that is visible..

If set prior to populating the combobox, the popup view will not be affected and will show the first column.

See Also:
setModelColumn

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 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 c to use instead of the current completer. If c 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)

Sets the index of the current item in the combobox. The index can change when inserting or removing items. Returns -1 if no current item is set or the combobox is empty. to index.

See Also:
currentIndex

setDuplicatesEnabled

public final void setDuplicatesEnabled(boolean enable)

Sets whether the user can enter duplicate items into the combobox to enable.

Note that it is always possible to programmatically insert duplicate items into the combobox.

See Also:
duplicatesEnabled

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)

Sets whether the combobox can be edited by the user to editable.

See Also:
isEditable

setFrame

public final void setFrame(boolean arg__1)

Sets whether the combo box draws itself with a frame to arg__1.

If enabled (the default) the combo box draws itself inside a frame, otherwise the combo box draws itself without any frame.

See Also:
hasFrame

setIconSize

public final void setIconSize(QSize size)

Sets the size of the icons shown in the combobox. to size.

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.

See Also:
iconSize

setInsertPolicy

public final void setInsertPolicy(QComboBox.InsertPolicy policy)

Sets the policy used to determine where user-inserted items should appear in the combobox to policy.

The default value is AtBottom, indicating that new items will appear at the bottom of the list of items.

See Also:
insertPolicy, InsertPolicy

setItemData

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

Equivalent to setItemData(index, value, Qt::UserRole).


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)

Sets the maximum number of items allowed in the combobox to max.

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.

See Also:
maxCount

setMaxVisibleItems

public final void setMaxVisibleItems(int maxItems)

Sets the maximum allowed size on screen of the combobox to maxItems.

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

See Also:
maxVisibleItems

setMinimumContentsLength

public final void setMinimumContentsLength(int characters)

Sets the minimum number of characters that should fit into the combobox. to characters.

The default value is 0.

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

See Also:
minimumContentsLength, 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, clear

setModelColumn

public final void setModelColumn(int visibleColumn)

Sets the column in the model that is visible. to visibleColumn.

If set prior to populating the combobox, the popup view will not be affected and will show the first column.

See Also:
modelColumn

setRootModelIndex

public final void setRootModelIndex(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)

Sets the policy describing how the size of the combobox changes when the content changes to policy.

The default value is AdjustToContentsOnFirstShow.

See Also:
sizeAdjustPolicy, SizeAdjustPolicy

setValidator

public final void setValidator(QValidator v)

Sets the v 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()

Returns the policy describing how the size of the combobox changes when the content changes.

The default value is AdjustToContentsOnFirstShow.

See Also:
setSizeAdjustPolicy, SizeAdjustPolicy

validator

public final QValidator validator()

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

See Also:
setValidator, editable

view

public final QAbstractItemView view()

Returns the list view used for the combobox popup.

See Also:
setView

changeEvent

protected void changeEvent(QEvent e)

This function is reimplemented for internal reasons.

Overrides:
changeEvent in class QWidget

contextMenuEvent

protected void contextMenuEvent(QContextMenuEvent e)

This function is reimplemented for internal reasons.

Overrides:
contextMenuEvent in class QWidget
See Also:
event, QContextMenuEvent, customContextMenuRequested

event

public boolean event(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

focusInEvent

protected void focusInEvent(QFocusEvent e)

This function is reimplemented for internal reasons.

Overrides:
focusInEvent in class QWidget
See Also:
focusOutEvent, setFocusPolicy, keyPressEvent, keyReleaseEvent, event, QFocusEvent

focusOutEvent

protected void focusOutEvent(QFocusEvent e)

This function is reimplemented for internal reasons.

Overrides:
focusOutEvent in class QWidget
See Also:
focusInEvent, setFocusPolicy, keyPressEvent, keyReleaseEvent, event, QFocusEvent

hideEvent

protected void hideEvent(QHideEvent e)

This function is reimplemented for internal reasons.

Overrides:
hideEvent in class QWidget
See Also:
visible, event, QHideEvent

hidePopup

public void hidePopup()

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


inputMethodEvent

protected void inputMethodEvent(QInputMethodEvent arg__1)

This function is reimplemented for internal reasons.

Overrides:
inputMethodEvent in class QWidget
See Also:
event, QInputMethodEvent

inputMethodQuery

public java.lang.Object inputMethodQuery(Qt.InputMethodQuery arg__1)

This function is reimplemented for internal reasons.

Overrides:
inputMethodQuery in class QWidget
See Also:
inputMethodEvent, QInputMethodEvent, QInputContext

keyPressEvent

protected void keyPressEvent(QKeyEvent e)

This function is reimplemented for internal reasons.

Overrides:
keyPressEvent in class QWidget
See Also:
keyReleaseEvent, QKeyEvent::ignore, setFocusPolicy, focusInEvent, focusOutEvent, event, QKeyEvent, Tetrix Example

keyReleaseEvent

protected void keyReleaseEvent(QKeyEvent e)

This function is reimplemented for internal reasons.

Overrides:
keyReleaseEvent in class QWidget
See Also:
keyPressEvent, QKeyEvent::ignore, setFocusPolicy, focusInEvent, focusOutEvent, event, QKeyEvent

minimumSizeHint

public QSize minimumSizeHint()

This function is reimplemented for internal reasons.

Overrides:
minimumSizeHint in class QWidget
See Also:
QSize::isValid, resize, setMinimumSize, sizePolicy

mousePressEvent

protected void mousePressEvent(QMouseEvent e)

This function is reimplemented for internal reasons.

Overrides:
mousePressEvent in class QWidget
See Also:
mouseReleaseEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

mouseReleaseEvent

protected void mouseReleaseEvent(QMouseEvent e)

This function is reimplemented for internal reasons.

Overrides:
mouseReleaseEvent in class QWidget
See Also:
mousePressEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

paintEvent

protected void paintEvent(QPaintEvent e)

This function is reimplemented for internal reasons.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

resizeEvent

protected void resizeEvent(QResizeEvent e)

This function is reimplemented for internal reasons.

Overrides:
resizeEvent in class QWidget
See Also:
moveEvent, event, resize, QResizeEvent, paintEvent, Example

showEvent

protected void showEvent(QShowEvent e)

This function is reimplemented for internal reasons.

Overrides:
showEvent in class QWidget
See Also:
visible, event, QShowEvent

showPopup

public void showPopup()

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


sizeHint

public QSize sizeHint()

This function is reimplemented for internal reasons.

Overrides:
sizeHint in class QWidget
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

wheelEvent

protected void wheelEvent(QWheelEvent e)

This function is reimplemented for internal reasons.

Overrides:
wheelEvent in class QWidget
See Also:
QWheelEvent::ignore, QWheelEvent::accept, event, QWheelEvent

fromNativePointer

public static QComboBox fromNativePointer(QNativePointer nativePointer)
This function returns the QComboBox instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

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.


Qt Jambi Home