|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QComboBox
public class QComboBox
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.
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.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 event handler can be reimplemented to handle state changes. |
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 event handler, for event arg__1, can be reimplemented in a subclass to receive widget context menu events. |
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 is the main event handler; it handles event arg__1. |
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 event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. |
protected void |
focusOutEvent(QFocusEvent e)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. |
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 event handler can be reimplemented in a subclass to receive widget hide events. |
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 event handler, for event arg__1, can be reimplemented in a subclass to receive Input Method composition events. |
java.lang.Object |
inputMethodQuery(Qt.InputMethodQuery arg__1)
This method is only relevant for input widgets. |
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 event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget. |
protected void |
keyReleaseEvent(QKeyEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive key release events for the widget. |
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()
Returns the recommended minimum size for the widget. |
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 event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget. |
protected void |
mouseReleaseEvent(QMouseEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget. |
protected void |
paintEvent(QPaintEvent e)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter. |
void |
removeItem(int index)
Removes the item at the given index from the combobox. |
protected void |
resizeEvent(QResizeEvent e)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. |
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. |
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. |
void |
setModel(QAbstractItemModel model)
Sets the model to be model. |
void |
setModelColumn(int visibleColumn)
Sets the column in the model that is visible. |
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 event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter. |
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()
Returns the recommended size for the widget. |
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 event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget. |
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 |
---|
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.
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.
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.
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.
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.
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.
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.
Constructor Detail |
---|
public QComboBox()
Equivalent to QComboBox(0).
public QComboBox(QWidget parent)
Constructs a combobox with the given parent, using the default model QStandardItemModel.
Method Detail |
---|
public final void addItem(java.lang.String text)
Equivalent to addItem(text, QVariant()).
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.
public final void addItem(QIcon icon, java.lang.String text)
Equivalent to addItem(icon, text, QVariant()).
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.
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.
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.
public final void clearEditText()
Clears the contents of the line edit used for editing in the combobox.
public final QCompleter completer()
Returns the completer that is used to auto complete text input for the combobox.
editable
public final int count()
Returns the number of items in the combobox.
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..
public final java.lang.String currentText()
Returns the text of the current item.
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.
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.
public final int findData(java.lang.Object data, int role)
Equivalent to findData(data, role, Qt::MatchExactly | Qt::MatchCaseSensitive).
public final int findData(java.lang.Object data)
Equivalent to findData(data, Qt::UserRole, Qt::MatchExactly | Qt::MatchCaseSensitive).
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.
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.
public final int findText(java.lang.String text)
Equivalent to findText(text, Qt::MatchExactly | Qt::MatchCaseSensitive).
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.
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.
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.
public final void insertItem(int index, QIcon icon, java.lang.String text)
Equivalent to insertItem(index, icon, text, QVariant()).
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.
public final void insertItem(int index, java.lang.String text)
Equivalent to insertItem(index, text, QVariant()).
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.
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.
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.
public final boolean isEditable()
Returns whether the combobox can be edited by the user.
public final java.lang.Object itemData(int index)
Equivalent to itemData(index, Qt::UserRole).
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.
public final QAbstractItemDelegate itemDelegate()
Returns the item delegate used by the popup list view.
public final QIcon itemIcon(int index)
Returns the icon for the given index in the combobox.
public final java.lang.String itemText(int index)
Returns the text for the given index in the combobox.
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.
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.
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.
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.
public final QAbstractItemModel model()
Returns the model used by the combobox.
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.
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.
public final QModelIndex rootModelIndex()
Returns the root model item index for the items in the combobox.
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.
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.
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.
public final void setEditText(java.lang.String text)
Sets the text in the combobox's text edit.
public final void setEditable(boolean editable)
Sets whether the combobox can be edited by the user to editable.
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.
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.
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.
public final void setItemData(int index, java.lang.Object value)
Equivalent to setItemData(index, value, Qt::UserRole).
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.
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.
public final void setItemIcon(int index, QIcon icon)
Sets the icon for the item on the given index in the combobox.
public final void setItemText(int index, java.lang.String text)
Sets the text for the item on the given index in the combobox.
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.
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.
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.
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.
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.
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.
public final void setRootModelIndex(QModelIndex index)
Sets the root model item index for the items in the combobox.
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.
public final void setValidator(QValidator v)
Sets the v to use instead of the current validator.
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.
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.
public final QValidator validator()
Returns the validator that is used to constrain text input for the combobox.
editable
public final QAbstractItemView view()
Returns the list view used for the combobox popup.
protected void changeEvent(QEvent e)
This event handler can be reimplemented to handle state changes.
The state being changed in this event can be retrieved through event arg__1.
Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.
changeEvent
in class QWidget
protected void contextMenuEvent(QContextMenuEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive widget context menu events.
The handler is called when the widget's contextMenuPolicy is Qt::DefaultContextMenu.
The default implementation ignores the context event. See the QContextMenuEvent documentation for more details.
contextMenuEvent
in class QWidget
public boolean event(QEvent event)
This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.
Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.
Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.
This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.
event
in class QWidget
protected void focusInEvent(QFocusEvent e)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. The event is passed in the arg__1 parameter
A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for windows that do not specify a focusPolicy).
focusInEvent
in class QWidget
protected void focusOutEvent(QFocusEvent e)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. The events is passed in the arg__1 parameter.
A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for windows that do not specify a focusPolicy).
focusOutEvent
in class QWidget
protected void hideEvent(QHideEvent e)
This event handler can be reimplemented in a subclass to receive widget hide events. The event is passed in the arg__1 parameter.
Hide events are sent to widgets immediately after they have been hidden.
Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible.
hideEvent
in class QWidget
visible
,
event,
QHideEventpublic void hidePopup()
Hides the list of items in the combobox if it is currently visible; otherwise this function does nothing.
protected void inputMethodEvent(QInputMethodEvent arg__1)
This event handler, for event arg__1, can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the state of the input method changes.
Note that when creating custom text editing widgets, the Qt::WA_InputMethodEnabled window attribute must be set explicitly (using the setAttribute function) in order to receive input method events.
The default implementation calls event->ignore(), which rejects the Input Method event. See the QInputMethodEvent documentation for more details.
inputMethodEvent
in class QWidget
public java.lang.Object inputMethodQuery(Qt.InputMethodQuery arg__1)
This method is only relevant for input widgets. It is used by the input method to query a set of properties of the widget to be able to support complex input method operations as support for surrounding text and reconversions.
arg__1 specifies which property is queried.
inputMethodQuery
in class QWidget
protected void keyPressEvent(QKeyEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget.
A widget must call setFocusPolicy to accept focus initially and have focus in order to receive a key press event.
If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.
keyPressEvent
in class QWidget
protected void keyReleaseEvent(QKeyEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive key release events for the widget.
A widget must accept focus initially and have focus in order to receive a key release event.
If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it.
The default implementation ignores the event.
keyReleaseEvent
in class QWidget
public QSize minimumSizeHint()
Returns the recommended minimum size for the widget.
If the value of this property is an invalid size, no minimum size is recommended.
The default implementation of minimumSizeHint returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint.
QLayout will never resize a widget to a size smaller than the minimum size hint unless minimumSize is set or the size policy is set to QSizePolicy::Ignore. If minimumSize is set, the minimum size hint will be ignored.
minimumSizeHint
in class QWidget
protected void mousePressEvent(QMouseEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
mousePressEvent
in class QWidget
Example
protected void mouseReleaseEvent(QMouseEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget.
mouseReleaseEvent
in class QWidget
Example
protected void paintEvent(QPaintEvent e)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.
The background can be set using setBackgroundRole and setPalette.
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
... extern void qt_x11_set_global_double_buffer(bool); qt_x11_set_global_double_buffer(false); ...
Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.
paintEvent
in class QWidget
protected void resizeEvent(QResizeEvent e)
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. When resizeEvent is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
resizeEvent
in class QWidget
Example
protected void showEvent(QShowEvent e)
This event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter.
Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.
Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible.
showEvent
in class QWidget
visible
,
event,
QShowEventpublic void showPopup()
Displays the list of items in the combobox. If the list is empty then the no items will be shown.
public QSize sizeHint()
Returns the recommended size for the widget.
If the value of this property is an invalid size, no size is recommended.
The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.
sizeHint
in class QWidget
protected void wheelEvent(QWheelEvent e)
This event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget.
If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.
The default implementation ignores the event.
wheelEvent
in class QWidget
public static QComboBox fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.protected final void initStyleOption(QStyleOptionComboBox option)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |