#include <qcombobox.h>
Inheritance diagram for QComboBox:


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 changeItem() functions are suitably overloaded. For editable comboboxes, the function clearEdit() 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, insertStringList() and insertItem() for example. Items can be changed with changeItem(). 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().
Comboboxes in the different built-in styles.
Definition at line 43 of file qcombobox.h.
Public Types | |
| enum | InsertPolicy |
| enum | SizeAdjustPolicy |
Public Slots | |
| void | clear () |
| void | clearEditText () |
| void | setEditText (const QString &text) |
| void | setCurrentIndex (int index) |
Signals | |
| void | editTextChanged (const QString &) |
| void | activated (int index) |
| void | activated (const QString &) |
| void | highlighted (int index) |
| void | highlighted (const QString &) |
| void | currentIndexChanged (int index) |
| void | currentIndexChanged (const QString &) |
Public Member Functions | |
| QComboBox (QWidget *parent=0) | |
| ~QComboBox () | |
| int | maxVisibleItems () const |
| void | setMaxVisibleItems (int maxItems) |
| int | count () const |
| void | setMaxCount (int max) |
| int | maxCount () const |
| bool | autoCompletion () const |
| void | setAutoCompletion (bool enable) |
| Qt::CaseSensitivity | autoCompletionCaseSensitivity () const |
| void | setAutoCompletionCaseSensitivity (Qt::CaseSensitivity sensitivity) |
| bool | duplicatesEnabled () const |
| void | setDuplicatesEnabled (bool enable) |
| void | setFrame (bool) |
| bool | hasFrame () const |
| int | findText (const QString &text, Qt::MatchFlags flags=Qt::MatchExactly|Qt::MatchCaseSensitive) const |
| int | findData (const QVariant &data, int role=Qt::UserRole, Qt::MatchFlags flags=Qt::MatchExactly|Qt::MatchCaseSensitive) const |
| InsertPolicy | insertPolicy () const |
| void | setInsertPolicy (InsertPolicy policy) |
| SizeAdjustPolicy | sizeAdjustPolicy () const |
| void | setSizeAdjustPolicy (SizeAdjustPolicy policy) |
| int | minimumContentsLength () const |
| void | setMinimumContentsLength (int characters) |
| QSize | iconSize () const |
| void | setIconSize (const QSize &size) |
| bool | isEditable () const |
| void | setEditable (bool editable) |
| void | setLineEdit (QLineEdit *edit) |
| QLineEdit * | lineEdit () const |
| void | setValidator (const QValidator *v) |
| const QValidator * | validator () const |
| void | setCompleter (QCompleter *c) |
| QCompleter * | completer () const |
| QAbstractItemDelegate * | itemDelegate () const |
| void | setItemDelegate (QAbstractItemDelegate *delegate) |
| QAbstractItemModel * | model () const |
| void | setModel (QAbstractItemModel *model) |
| QModelIndex | rootModelIndex () const |
| void | setRootModelIndex (const QModelIndex &index) |
| int | modelColumn () const |
| void | setModelColumn (int visibleColumn) |
| int | currentIndex () const |
| QString | currentText () const |
| QString | itemText (int index) const |
| QIcon | itemIcon (int index) const |
| QVariant | itemData (int index, int role=Qt::UserRole) const |
| void | addItem (const QString &text, const QVariant &userData=QVariant()) |
| void | addItem (const QIcon &icon, const QString &text, const QVariant &userData=QVariant()) |
| void | addItems (const QStringList &texts) |
| void | insertItem (int index, const QString &text, const QVariant &userData=QVariant()) |
| void | insertItem (int index, const QIcon &icon, const QString &text, const QVariant &userData=QVariant()) |
| void | insertItems (int index, const QStringList &texts) |
| void | removeItem (int index) |
| void | setItemText (int index, const QString &text) |
| void | setItemIcon (int index, const QIcon &icon) |
| void | setItemData (int index, const QVariant &value, int role=Qt::UserRole) |
| QAbstractItemView * | view () const |
| void | setView (QAbstractItemView *itemView) |
| QSize | sizeHint () const |
| QSize | minimumSizeHint () const |
| virtual void | showPopup () |
| virtual void | hidePopup () |
| bool | event (QEvent *event) |
Protected Member Functions | |
| void | focusInEvent (QFocusEvent *e) |
| void | focusOutEvent (QFocusEvent *e) |
| void | changeEvent (QEvent *e) |
| void | resizeEvent (QResizeEvent *e) |
| void | paintEvent (QPaintEvent *e) |
| void | showEvent (QShowEvent *e) |
| void | hideEvent (QHideEvent *e) |
| void | mousePressEvent (QMouseEvent *e) |
| void | mouseReleaseEvent (QMouseEvent *e) |
| void | keyPressEvent (QKeyEvent *e) |
| void | keyReleaseEvent (QKeyEvent *e) |
| void | wheelEvent (QWheelEvent *e) |
| void | contextMenuEvent (QContextMenuEvent *e) |
| void | inputMethodEvent (QInputMethodEvent *) |
| QVariant | inputMethodQuery (Qt::InputMethodQuery) const |
| QComboBox (QComboBoxPrivate &, QWidget *) | |
Private Member Functions | |
| Q_PRIVATE_SLOT (d_func(), void _q_itemSelected(const QModelIndex &item)) Q_PRIVATE_SLOT(d_func() | |
| void | _q_emitHighlighted (const QModelIndex &)) Q_PRIVATE_SLOT(d_func() |
| void void | _q_emitCurrentIndexChanged (int index)) Q_PRIVATE_SLOT(d_func() |
| void void void | _q_returnPressed ()) Q_PRIVATE_SLOT(d_func() |
| void void void void | _q_resetButton ()) Q_PRIVATE_SLOT(d_func() |
| void void void void void | _q_dataChanged (const QModelIndex &, const QModelIndex &)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void | _q_rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void void | _q_rowsInserted (const QModelIndex &parent, int start, int end)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void void void | _q_rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void void void void | _q_rowsRemoved (const QModelIndex &parent, int start, int end)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void void void void void | _q_modelDestroyed ()) Q_PRIVATE_SLOT(d_func() |
This enum specifies what the QComboBox should do when a new string is entered by the user.
NoInsert The string will not be inserted into the combobox. InsertAtTop The string will be inserted as the first item in the combobox. InsertAtCurrent The current item will be replaced by the string. InsertAtBottom The string will be inserted after the last item in the combobox. InsertAfterCurrent The string is inserted after the current item in the combobox. InsertBeforeCurrent The string is inserted before the current item in the combobox. InsertAlphabetically The string is inserted in the alphabetic order in the combobox. NoInsertion AtTop AtCurrent AtBottom AfterCurrent BeforeCurrent
Definition at line 100 of file qcombobox.h.
00100 { 00101 NoInsert, 00102 InsertAtTop, 00103 InsertAtCurrent, 00104 InsertAtBottom, 00105 InsertAfterCurrent, 00106 InsertBeforeCurrent, 00107 InsertAlphabetically 00108 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) 00109 , 00110 NoInsertion = NoInsert, 00111 AtTop = InsertAtTop, 00112 AtCurrent = InsertAtCurrent, 00113 AtBottom = InsertAtBottom, 00114 AfterCurrent = InsertAfterCurrent, 00115 BeforeCurrent = InsertBeforeCurrent 00116 #endif 00117 };
This enum specifies how the size hint of the QComboBox should adjust when new content is added or content changes.
AdjustToContents The combobox will always adjust to the contents AdjustToContentsOnFirstShow The combobox will adjust to its contents the first time it is show. AdjustToMinimumContentsLength Use AdjustToContents or AdjustToContentsOnFirstShow instead.
Definition at line 125 of file qcombobox.h.
00125 { 00126 AdjustToContents, 00127 AdjustToContentsOnFirstShow, 00128 AdjustToMinimumContentsLength // ### remove in Qt 5 00129 };
| QComboBox::QComboBox | ( | QWidget * | parent = 0 |
) | [explicit] |
Constructs a combobox with the given parent, using the default model QStandardItemModel.
Definition at line 636 of file qcombobox.cpp.
References d.
00637 : QWidget(*new QComboBoxPrivate(), parent, 0) 00638 { 00639 Q_D(QComboBox); 00640 d->init(); 00641 }
| QComboBox::~QComboBox | ( | ) |
Destroys the combobox.
Definition at line 1029 of file qcombobox.cpp.
References _q_modelDestroyed(), d, QObject::destroyed(), QObject::disconnect(), SIGNAL, and SLOT.
01030 { 01031 // ### check delegateparent and delete delegate if us? 01032 Q_D(QComboBox); 01033 01034 disconnect(d->model, SIGNAL(destroyed()), 01035 this, SLOT(_q_modelDestroyed())); 01036 }
Here is the call graph for this function:

| QComboBox::QComboBox | ( | QComboBoxPrivate & | , | |
| QWidget * | ||||
| ) | [protected] |
| int QComboBox::maxVisibleItems | ( | ) | const |
| void QComboBox::setMaxVisibleItems | ( | int | maxItems | ) |
Definition at line 1051 of file qcombobox.cpp.
References d, and qWarning().
01052 { 01053 Q_D(QComboBox); 01054 if (maxItems < 0) { 01055 qWarning("QComboBox::setMaxVisibleItems: " 01056 "Invalid max visible items (%d) must be >= 0", maxItems); 01057 return; 01058 } 01059 d->maxVisibleItems = maxItems; 01060 }
Here is the call graph for this function:

| int QComboBox::count | ( | ) | const |
Definition at line 1066 of file qcombobox.cpp.
References model(), rootModelIndex(), and QAbstractItemModel::rowCount().
Referenced by Q3FileDialog::addFilter(), addItem(), Q3Action::addTo(), TrPreviewTool::addTranslator(), FindFileDialog::browse(), qdesigner_internal::ChangeListContentsCommand::changeContents(), qdesigner_internal::ListWidgetEditor::fillContentsFromComboBox(), MainWindow::findSizes(), Window::iconActivated(), qdesigner_internal::GraphicsPropertyEditor::indexOfIcon(), qdesigner_internal::GraphicsPropertyEditor::indexOfPixmap(), qdesigner_internal::ChangeListContentsCommand::init(), qdesigner_internal::ResourceEditor::insertEmptyComboItem(), insertItem(), insertItems(), MultiPageWidget::insertPage(), keyPressEvent(), QAbstractFormBuilder::loadComboBoxExtraInfo(), TrPreviewTool::loadTranslation(), Q3FileDialog::Q3FileDialog(), qdesigner_internal::ResourceEditor::removeEmptyComboItem(), removeItem(), QAbstractFormBuilder::saveComboBoxExtraInfo(), Q3FileDialog::setFilter(), setMaxCount(), Q3FileDialog::setMode(), setModel(), Q3FileDialog::setSelectedFilter(), showPopup(), QFileDialogPrivate::updateButtons(), qdesigner_internal::FlagsProperty::updateValue(), and wheelEvent().
01067 { 01068 return model()->rowCount(rootModelIndex()); 01069 }
Here is the call graph for this function:

| void QComboBox::setMaxCount | ( | int | max | ) |
Definition at line 1080 of file qcombobox.cpp.
References count(), d, model(), qWarning(), QAbstractItemModel::removeRows(), and rootModelIndex().
01081 { 01082 Q_D(QComboBox); 01083 if (max < 0) { 01084 qWarning("QComboBox::setMaxCount: Invalid count (%d) must be >= 0", max); 01085 return; 01086 } 01087 01088 if (max < count()) 01089 model()->removeRows(max, count() - max, rootModelIndex()); 01090 01091 d->maxCount = max; 01092 }
Here is the call graph for this function:

| int QComboBox::maxCount | ( | ) | const |
| bool QComboBox::autoCompletion | ( | ) | const |
| void QComboBox::setAutoCompletion | ( | bool | enable | ) |
Use setCompleter() instead.
Definition at line 1129 of file qcombobox.cpp.
References d, QCompleter::InlineCompletion, and model().
Referenced by setLineEdit(), and QFileDialogPrivate::setupWidgets().
01130 { 01131 Q_D(QComboBox); 01132 d->autoCompletion = enable; 01133 if (!d->lineEdit) 01134 return; 01135 if (enable) { 01136 if (d->lineEdit->completer()) 01137 return; 01138 d->completer = new QCompleter(d->lineEdit); 01139 d->completer->setCaseSensitivity(d->autoCompletionCaseSensitivity); 01140 d->completer->setCompletionMode(QCompleter::InlineCompletion); 01141 d->completer->setModel(model()); 01142 d->completer->setCompletionColumn(d->modelColumn); 01143 d->lineEdit->setCompleter(d->completer); 01144 d->completer->setWidget(this); 01145 } else { 01146 d->lineEdit->setCompleter(0); 01147 } 01148 }
Here is the call graph for this function:

| Qt::CaseSensitivity QComboBox::autoCompletionCaseSensitivity | ( | ) | const |
Use setCompleter() and QCompleter::setCaseSensitivity() instead.
Definition at line 1168 of file qcombobox.cpp.
References d.
| void QComboBox::setAutoCompletionCaseSensitivity | ( | Qt::CaseSensitivity | sensitivity | ) |
Use setCompleter() and QCompleter::setCaseSensitivity() instead.
Definition at line 1179 of file qcombobox.cpp.
References d.
01180 { 01181 Q_D(QComboBox); 01182 d->autoCompletionCaseSensitivity = sensitivity; 01183 if (d->lineEdit && d->lineEdit->completer()) 01184 d->lineEdit->completer()->setCaseSensitivity(sensitivity); 01185 }
| bool QComboBox::duplicatesEnabled | ( | ) | const |
| void QComboBox::setDuplicatesEnabled | ( | bool | enable | ) |
Definition at line 1202 of file qcombobox.cpp.
References d.
Referenced by Q3FileDialog::init(), and QFileDialogPrivate::setupWidgets().
| void QComboBox::setFrame | ( | bool | ) |
Definition at line 2603 of file qcombobox.cpp.
References d, QWidget::update(), and QWidget::updateGeometry().
Referenced by qdesigner_internal::BoolProperty::createEditor(), qdesigner_internal::CursorProperty::createEditor(), qdesigner_internal::MapProperty::createEditor(), qdesigner_internal::ListProperty::createEditor(), QDefaultItemEditorFactory::createEditor(), qdesigner_internal::GraphicsPropertyEditor::init(), and qdesigner_internal::InlineEditor::InlineEditor().
02604 { 02605 Q_D(QComboBox); 02606 d->frame = enable; 02607 update(); 02608 updateGeometry(); 02609 }
Here is the call graph for this function:

| bool QComboBox::hasFrame | ( | ) | const |
| int QComboBox::findText | ( | const QString & | text, | |
| Qt::MatchFlags | flags = Qt::MatchExactly|Qt::MatchCaseSensitive | |||
| ) | const [inline] |
Returns the index of the item containing the given text; otherwise returns -1.
The flags specify how the items in the combobox are searched.
Definition at line 94 of file qcombobox.h.
References Qt::EditRole, and flags.
Referenced by TrPreviewTool::addTranslator(), MainWindow::findSizes(), MainWindow::findStyles(), TextEdit::fontChanged(), TrPreviewTool::loadTranslation(), ImageDelegate::setEditorData(), QFileDialogPrivate::setup(), TextEdit::setupTextActions(), qdesigner_internal::RichTextEditorToolBar::updateActions(), and QFileDialogPrivate::updateButtons().
00096 { return findData(text, Qt::EditRole, flags); }
| int QComboBox::findData | ( | const QVariant & | data, | |
| int | role = Qt::UserRole, |
|||
| Qt::MatchFlags | flags = Qt::MatchExactly|Qt::MatchCaseSensitive | |||
| ) | const |
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.
Definition at line 1222 of file qcombobox.cpp.
References d, data, QList< T >::first(), QAbstractItemModel::index(), QList< T >::isEmpty(), QAbstractItemModel::match(), model(), rootModelIndex(), and start.
Referenced by TrPreviewTool::addTranslator(), and TrPreviewTool::loadTranslation().
01223 { 01224 Q_D(const QComboBox); 01225 QModelIndexList result; 01226 QModelIndex start = model()->index(0, d->modelColumn, rootModelIndex()); 01227 result = model()->match(start, role, data, 1, flags); 01228 if (result.isEmpty()) 01229 return -1; 01230 return result.first().row(); 01231 }
Here is the call graph for this function:

| QComboBox::InsertPolicy QComboBox::insertPolicy | ( | ) | const |
| void QComboBox::setInsertPolicy | ( | InsertPolicy | policy | ) |
Definition at line 1250 of file qcombobox.cpp.
References d.
Referenced by QFileDialogPrivate::setupWidgets().
| QComboBox::SizeAdjustPolicy QComboBox::sizeAdjustPolicy | ( | ) | const |
| void QComboBox::setSizeAdjustPolicy | ( | SizeAdjustPolicy | policy | ) |
Definition at line 1272 of file qcombobox.cpp.
References d, and QWidget::updateGeometry().
Referenced by FindFileDialog::createComboBoxes(), and QFileDialogPrivate::setupWidgets().
01273 { 01274 Q_D(QComboBox); 01275 if (policy == d->sizeAdjustPolicy) 01276 return; 01277 01278 d->sizeAdjustPolicy = policy; 01279 d->sizeHint = QSize(); 01280 updateGeometry(); 01281 }
Here is the call graph for this function:

| int QComboBox::minimumContentsLength | ( | ) | const |
| void QComboBox::setMinimumContentsLength | ( | int | characters | ) |
Definition at line 1300 of file qcombobox.cpp.
References AdjustToContents, AdjustToMinimumContentsLength, d, and QWidget::updateGeometry().
Referenced by FindFileDialog::createComboBoxes().
01301 { 01302 Q_D(QComboBox); 01303 if (characters == d->minimumContentsLength || characters < 0) 01304 return; 01305 01306 d->minimumContentsLength = characters; 01307 01308 if (d->sizeAdjustPolicy == AdjustToContents 01309 || d->sizeAdjustPolicy == AdjustToMinimumContentsLength) { 01310 d->sizeHint = QSize(); 01311 updateGeometry(); 01312 } 01313 }
Here is the call graph for this function:

| QSize QComboBox::iconSize | ( | ) | const |
Definition at line 1322 of file qcombobox.cpp.
References d, QStyle::pixelMetric(), QStyle::PM_SmallIconSize, and QWidget::style().
01323 { 01324 Q_D(const QComboBox); 01325 if (d->iconSize.isValid()) 01326 return d->iconSize; 01327 01328 int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize); 01329 return QSize(iconWidth, iconWidth); 01330 }
Here is the call graph for this function:

| void QComboBox::setIconSize | ( | const QSize & | size | ) |
Definition at line 1332 of file qcombobox.cpp.
References d, QAbstractItemView::setIconSize(), QWidget::size(), QWidget::updateGeometry(), and view().
01333 { 01334 Q_D(QComboBox); 01335 if (size == d->iconSize) 01336 return; 01337 01338 view()->setIconSize(size); 01339 d->iconSize = size; 01340 d->sizeHint = QSize(); 01341 updateGeometry(); 01342 }
Here is the call graph for this function:

| bool QComboBox::isEditable | ( | ) | const |
Definition at line 1348 of file qcombobox.cpp.
References d.
Referenced by QComboBoxPrivateContainer::comboStyleOption(), qdesigner_internal::FlagBox::FlagBox(), hidePopup(), QComboBoxPrivateContainer::mousePressEvent(), mousePressEvent(), and setEditable().
| void QComboBox::setEditable | ( | bool | editable | ) |
Definition at line 1354 of file qcombobox.cpp.
References d, isEditable(), Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded, QWidget::setAttribute(), setItemDelegate(), QWidget::setLayoutDirection(), setLineEdit(), QAbstractScrollArea::setVerticalScrollBarPolicy(), QStyle::SH_ComboBox_LayoutDirection, QStyle::SH_ComboBox_Popup, QWidget::style(), styleHint(), view(), and Qt::WA_InputMethodEnabled.
Referenced by Window::createComboBox(), FindFileDialog::createComboBoxes(), MainWindow::findSizes(), Q3FileDialog::init(), QInputDialogPrivate::init(), qdesigner_internal::GraphicsPropertyEditor::init(), LocationDialog::LocationDialog(), QFontComboBox::QFontComboBox(), RegExpDialog::RegExpDialog(), qdesigner_internal::RichTextEditorToolBar::RichTextEditorToolBar(), TextEdit::setupTextActions(), QFileDialogPrivate::setupWidgets(), and MainWindow::useComboBox().
01355 { 01356 Q_D(QComboBox); 01357 if (isEditable() == editable) 01358 return; 01359 setAttribute(Qt::WA_InputMethodEnabled, editable); 01360 01361 QStyleOptionComboBox opt = d->getStyleOption(); 01362 if (editable) { 01363 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { 01364 setItemDelegate(new QItemDelegate(view())); 01365 d->viewContainer()->updateScrollers(); 01366 view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); 01367 } 01368 QLineEdit *le = new QLineEdit(this); 01369 le->setLayoutDirection(Qt::LayoutDirection( 01370 style()->styleHint(QStyle::SH_ComboBox_LayoutDirection, 01371 &opt, this))); 01372 setLineEdit(le); 01373 } else { 01374 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { 01375 setItemDelegate(new QComboMenuDelegate(view(), this)); 01376 d->viewContainer()->updateScrollers(); 01377 view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 01378 } 01379 delete d->lineEdit; 01380 d->lineEdit = 0; 01381 } 01382 }
Here is the call graph for this function:

| void QComboBox::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.
Definition at line 1389 of file qcombobox.cpp.
References _q_returnPressed(), QObject::connect(), currentText(), d, editTextChanged(), QWidget::isVisible(), Qt::NoContextMenu, qWarning(), QWidget::setAttribute(), setAutoCompletion(), QLineEdit::setText(), SIGNAL, SLOT, QWidget::update(), and Qt::WA_InputMethodEnabled.
Referenced by setEditable(), and QFileDialogPrivate::setupWidgets().
01390 { 01391 Q_D(QComboBox); 01392 if (!edit) { 01393 qWarning("QComboBox::setLineEdit: cannot set a 0 line edit"); 01394 return; 01395 } 01396 01397 if (edit == d->lineEdit) 01398 return; 01399 01400 edit->setText(currentText()); 01401 delete d->lineEdit; 01402 01403 d->lineEdit = edit; 01404 if (d->lineEdit->parent() != this) 01405 d->lineEdit->setParent(this); 01406 connect(d->lineEdit, SIGNAL(returnPressed()), this, SLOT(_q_returnPressed())); 01407 connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(editTextChanged(QString))); 01408 #ifdef QT3_SUPPORT 01409 connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); 01410 #endif 01411 d->lineEdit->setFrame(false); 01412 d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); 01413 d->lineEdit->setFocusProxy(this); 01414 #ifndef QT_NO_COMPLETER 01415 setAutoCompletion(d->autoCompletion); 01416 #endif 01417 setAttribute(Qt::WA_InputMethodEnabled); 01418 d->updateLineEditGeometry(); 01419 01420 if (isVisible()) 01421 d->lineEdit->show(); 01422 01423 update(); 01424 }
Here is the call graph for this function:

| QLineEdit * QComboBox::lineEdit | ( | ) | const |
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.
Definition at line 1432 of file qcombobox.cpp.
References d.
Referenced by QAccessibleComboBox::rect(), and QAccessibleComboBox::text().
| void QComboBox::setValidator | ( | const QValidator * | validator | ) |
| const QValidator * QComboBox::validator | ( | ) | const |
| void QComboBox::setCompleter | ( | QCompleter * | completer | ) |
By default, for an editable combo box, a QCompleter that performs case insensitive inline completion is automatically created.
Definition at line 1477 of file qcombobox.cpp.
Referenced by MainWindow::updateModel(), and MainWindow::useComboBox().
01478 { 01479 Q_D(QComboBox); 01480 if (!d->lineEdit) 01481 return; 01482 d->lineEdit->setCompleter(c); 01483 if (c) 01484 c->setWidget(this); 01485 }
| QCompleter * QComboBox::completer | ( | ) | const |
| QAbstractItemDelegate * QComboBox::itemDelegate | ( | ) | const |
Returns the item delegate used by the popup list view.
Definition at line 1508 of file qcombobox.cpp.
References QAbstractItemView::itemDelegate(), and view().
01509 { 01510 return view()->itemDelegate(); 01511 }
Here is the call graph for this function:

| void QComboBox::setItemDelegate | ( | QAbstractItemDelegate * | delegate | ) |
Sets the item delegate for the popup list view. The combobox takes ownership of the delegate.
Definition at line 1519 of file qcombobox.cpp.
References QAbstractItemView::itemDelegate(), qWarning(), QAbstractItemView::setItemDelegate(), and view().
Referenced by qdesigner_internal::FlagBox::FlagBox(), QFontComboBox::QFontComboBox(), and setEditable().
01520 { 01521 if (!delegate) { 01522 qWarning("QComboBox::setItemDelegate: cannot set a 0 delegate"); 01523 return; 01524 } 01525 delete view()->itemDelegate(); 01526 view()->setItemDelegate(delegate); 01527 }
Here is the call graph for this function:

| QAbstractItemModel * QComboBox::model | ( | ) | const |
Returns the model used by the combobox.
Definition at line 1533 of file qcombobox.cpp.
References d, setModel(), and QAbstractItemModelPrivate::staticEmptyModel().
Referenced by clear(), count(), findData(), insertItem(), insertItems(), itemData(), itemIcon(), itemText(), keyPressEvent(), removeItem(), setAutoCompletion(), setCurrentIndex(), setItemData(), setItemIcon(), setItemText(), setMaxCount(), setModel(), showPopup(), and wheelEvent().
01534 { 01535 Q_D(const QComboBox); 01536 if (d->model == QAbstractItemModelPrivate::staticEmptyModel()) { 01537 QComboBox *that = const_cast<QComboBox*>(this); 01538 that->setModel(new QStandardItemModel(0, 1, that)); 01539 } 01540 return d->model; 01541 }
Here is the call graph for this function:

| void QComboBox::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().
Definition at line 1549 of file qcombobox.cpp.
References _q_dataChanged(), _q_modelDestroyed(), _q_rowsAboutToBeInserted(), _q_rowsAboutToBeRemoved(), _q_rowsInserted(), _q_rowsRemoved(), QObject::connect(), count(), d, QObject::destroyed(), QObject::disconnect(), Qt::ItemIsEnabled, model(), QWidget::pos(), qWarning(), rootModelIndex(), setCurrentIndex(), SIGNAL, SLOT, and QAbstractItemModelPrivate::staticEmptyModel().
Referenced by qdesigner_internal::FlagBox::FlagBox(), qdesigner_internal::InlineEditor::InlineEditor(), model(), and QFontComboBox::QFontComboBox().
01550 { 01551 Q_D(QComboBox); 01552 if (!model) { 01553 qWarning("QComboBox::setModel: cannot set a 0 model"); 01554 return; 01555 } 01556 01557 #ifndef QT_NO_COMPLETER 01558 if (d->lineEdit && d->lineEdit->completer() 01559 && d->lineEdit->completer() == d->completer) 01560 d->lineEdit->completer()->setModel(model); 01561 #endif 01562 01563 disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01564 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01565 disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), 01566 this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); 01567 disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), 01568 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01569 disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), 01570 this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); 01571 disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 01572 this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); 01573 disconnect(d->model, SIGNAL(destroyed()), 01574 this, SLOT(_q_modelDestroyed())); 01575 disconnect(d->model, SIGNAL(modelReset()), 01576 this, SLOT(_q_modelReset())); 01577 if (d->model->QObject::parent() == this) 01578 delete d->model; 01579 01580 d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel()); 01581 01582 connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01583 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01584 connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), 01585 this, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); 01586 connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), 01587 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01588 connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), 01589 this, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); 01590 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 01591 this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); 01592 connect(model, SIGNAL(destroyed()), 01593 this, SLOT(_q_modelDestroyed())); 01594 connect(model, SIGNAL(modelReset()), 01595 this, SLOT(_q_modelReset())); 01596 01597 if (d->container) 01598 d->container->itemView()->setModel(model); 01599 01600 if (count()) { 01601 for (int pos=0; pos < count(); pos++) { 01602 if (d->model->index(pos, d->modelColumn, rootModelIndex()).flags() & Qt::ItemIsEnabled) { 01603 setCurrentIndex(pos); 01604 break; 01605 } 01606 } 01607 } else 01608 setCurrentIndex(-1); 01609 }
Here is the call graph for this function:

| QModelIndex QComboBox::rootModelIndex | ( | ) | const |
Returns the root model item index for the items in the combobox.
Definition at line 1617 of file qcombobox.cpp.
References d.
Referenced by clear(), count(), findData(), insertItem(), insertItems(), itemData(), itemIcon(), itemText(), keyPressEvent(), removeItem(), setCurrentIndex(), setItemData(), setItemIcon(), setItemText(), setMaxCount(), setModel(), showPopup(), and wheelEvent().
01618 { 01619 Q_D(const QComboBox); 01620 return QModelIndex(d->root); 01621 }
| void QComboBox::setRootModelIndex | ( | const QModelIndex & | index | ) |
Sets the root model item index for the items in the combobox.
Definition at line 1628 of file qcombobox.cpp.
References d, index, QAbstractItemView::setRootIndex(), QWidget::update(), and view().
01629 { 01630 Q_D(QComboBox); 01631 d->root = QPersistentModelIndex(index); 01632 view()->setRootIndex(index); 01633 update(); 01634 }
Here is the call graph for this function:

| int QComboBox::modelColumn | ( | ) | const |
| void QComboBox::setModelColumn | ( | int | visibleColumn | ) |
Definition at line 2621 of file qcombobox.cpp.
References d, and QListView::setModelColumn().
02622 { 02623 Q_D(QComboBox); 02624 d->modelColumn = visibleColumn; 02625 QListView *lv = qobject_cast<QListView *>(d->viewContainer()->itemView()); 02626 if (lv) 02627 lv->setModelColumn(visibleColumn); 02628 02629 #ifndef QT_NO_COMPLETER 02630 if (d->lineEdit && d->lineEdit->completer() 02631 && d->lineEdit->completer() == d->completer) 02632 d->lineEdit->completer()->setCompletionColumn(visibleColumn); 02633 #endif 02634 }
Here is the call graph for this function:

| int QComboBox::currentIndex | ( | ) | const |
Definition at line 1642 of file qcombobox.cpp.
References d.
Referenced by Window::browse(), Window::brushChanged(), Window::currentItemData(), ImageComposer::currentMode(), Window::filterColumnChanged(), Window::filterRegExpChanged(), LocationDialog::format(), QComboMenuDelegate::getStyleOption(), Window::iconActivated(), keyPressEvent(), Window::penChanged(), RegExpDialog::refresh(), TrPreviewTool::reloadTranslations(), LocationDialog::scope(), PPDOptionsEditor::setModelData(), Window::shapeChanged(), Window::showMessage(), showPopup(), Window::textFilterChanged(), MainWindow::updateModel(), PreviewForm::updateTextEdit(), qdesigner_internal::FlagsProperty::updateValue(), and wheelEvent().
| QString QComboBox::currentText | ( | ) | const |
Definition at line 1670 of file qcombobox.cpp.
References d.
Referenced by QFileDialogPrivate::_q_enterDirectory(), LocationDialog::application(), FindFileDialog::browse(), Window::createDateTimeEdits(), Window::find(), FindFileDialog::findFiles(), MainWindow::findSizes(), MainWindow::findStyles(), QInputDialog::getItem(), FindFileDialog::openFile(), LocationDialog::organization(), RegExpDialog::refresh(), SpreadSheet::runInputDialog(), Q3FileDialog::selectedFilter(), setLineEdit(), Q3FileDialog::setMode(), ImageDelegate::setModelData(), Q3FileDialog::setSelectedFilter(), QAccessibleComboBox::text(), and qdesigner_internal::InlineEditor::text().
01671 { 01672 Q_D(const QComboBox); 01673 if (d->lineEdit) 01674 return d->lineEdit->text(); 01675 else if (d->currentIndex.isValid()) 01676 return d->itemText(d->currentIndex); 01677 else 01678 return QString(); 01679 }
| QString QComboBox::itemText | ( | int | index | ) | const |
Returns the text for the given index in the combobox.
Definition at line 1684 of file qcombobox.cpp.
References d, QAbstractItemModel::index(), model(), and rootModelIndex().
Referenced by qdesigner_internal::ListWidgetEditor::fillContentsFromComboBox(), qdesigner_internal::ChangeListContentsCommand::init(), QAbstractFormBuilder::saveComboBoxExtraInfo(), setCurrentIndex(), and Window::setIcon().
01685 { 01686 Q_D(const QComboBox); 01687 QModelIndex mi = model()->index(index, d->modelColumn, rootModelIndex()); 01688 return d->itemText(mi); 01689 }
Here is the call graph for this function:

| QIcon QComboBox::itemIcon | ( | int | index | ) | const |
Returns the icon for the given index in the combobox.
Definition at line 1694 of file qcombobox.cpp.
References d, QAbstractItemModel::data(), Qt::DecorationRole, index, model(), QVariant::Pixmap, rootModelIndex(), and QVariant::type().
Referenced by qdesigner_internal::ChangeListContentsCommand::init(), and Window::setIcon().
01695 { 01696 Q_D(const QComboBox); 01697 QVariant decoration = model()->data(model()->index(index, d->modelColumn, rootModelIndex()), Qt::DecorationRole); 01698 if (decoration.type() == QVariant::Pixmap) 01699 return QIcon(qvariant_cast<QPixmap>(decoration)); 01700 else 01701 return qvariant_cast<QIcon>(decoration); 01702 }
Here is the call graph for this function:

| QVariant QComboBox::itemData | ( | int | index, | |
| int | role = Qt::UserRole | |||
| ) | const |
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.
Definition at line 1708 of file qcombobox.cpp.
References d, QAbstractItemModel::data(), QAbstractItemModel::index(), model(), and rootModelIndex().
Referenced by Window::brushChanged(), Dialog::buttonsOrientationChanged(), qdesigner_internal::GraphicsPropertyEditor::comboActivated(), Window::currentItemData(), qdesigner_internal::ListWidgetEditor::fillContentsFromComboBox(), Window::filterRegExpChanged(), qdesigner_internal::GraphicsPropertyEditor::indexOfIcon(), qdesigner_internal::GraphicsPropertyEditor::indexOfPixmap(), qdesigner_internal::ResourceEditor::insertEmptyComboItem(), Window::penChanged(), RegExpDialog::refresh(), qdesigner_internal::ResourceEditor::removeEmptyComboItem(), QAbstractFormBuilder::saveComboBoxExtraInfo(), qdesigner_internal::ResourceEditor::setCurrentIndex(), Window::shapeChanged(), Window::showMessage(), qdesigner_internal::FlagBox::slotActivated(), Window::textFilterChanged(), TrPreviewTool::translationSelected(), and PreviewForm::updateTextEdit().
01709 { 01710 Q_D(const QComboBox); 01711 QModelIndex mi = model()->index(index, d->modelColumn, rootModelIndex()); 01712 return model()->data(mi, role); 01713 }
Here is the call graph for this function:

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.
Definition at line 296 of file qcombobox.h.
Referenced by qdesigner_internal::CursorProperty::addCursor(), TrPreviewTool::addTranslator(), FindFileDialog::browse(), Window::browse(), qdesigner_internal::ChangeListContentsCommand::changeContents(), ConfigurationPage::ConfigurationPage(), Window::createComboBox(), Window::createControls(), Window::createDateTimeEdits(), ImageDelegate::createEditor(), QDefaultItemEditorFactory::createEditor(), Window::createIconGroupBox(), Window::createMessageGroupBox(), Dialog::createOptionsGroupBox(), FindFileDialog::FindFileDialog(), MainWindow::findSizes(), MainWindow::findStyles(), QAbstractFormBuilder::loadComboBoxExtraInfo(), TrPreviewTool::loadTranslation(), LocationDialog::LocationDialog(), qdesigner_internal::GraphicsPropertyEditor::populateCombo(), populatePaperSizes(), Window::populateWithColors(), RegExpDialog::RegExpDialog(), qdesigner_internal::RichTextEditorToolBar::RichTextEditorToolBar(), PreviewForm::setCodecList(), PPDOptionsEditor::setEditorData(), QFileDialogPrivate::setup(), TextEdit::setupTextActions(), QFileDialogPrivate::updateButtons(), qdesigner_internal::ResourceEditor::updateQrcStack(), and WidgetGallery::WidgetGallery().
00297 { insertItem(count(), atext, auserData); }
| void QComboBox::addItem | ( | const QIcon & | icon, | |
| const QString & | text, | |||
| const QVariant & | userData = QVariant() | |||
| ) | [inline] |
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.
Definition at line 298 of file qcombobox.h.
References count(), and insertItem().
00300 { insertItem(count(), aicon, atext, auserData); }
Here is the call graph for this function:

| void QComboBox::addItems | ( | const QStringList & | texts | ) | [inline] |
Adds each of the strings in the given texts to the combobox. Each item is appended to the list of existing items in turn.
Definition at line 175 of file qcombobox.h.
Referenced by qdesigner_internal::BoolProperty::createEditor(), qdesigner_internal::MapProperty::createEditor(), qdesigner_internal::ListProperty::createEditor(), QInputDialog::getItem(), SpreadSheet::runInputDialog(), QFileDialogPrivate::setup(), and WidgetGallery::WidgetGallery().
00176 { insertItems(count(), texts); }
| void QComboBox::insertItem | ( | int | index, | |
| const QString & | text, | |||
| const QVariant & | userData = QVariant() | |||
| ) | [inline] |
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.
Definition at line 302 of file qcombobox.h.
Referenced by Q3FileDialog::addFilter(), addItem(), Q3Action::addTo(), qdesigner_internal::ResourceEditor::addView(), Q3FileDialog::getExistingDirectory(), qdesigner_internal::ResourceEditor::insertEmptyComboItem(), MultiPageWidget::insertPage(), Q3FileDialog::Q3FileDialog(), Q3FileDialog::setFilter(), Q3FileDialog::setFilters(), and Q3FileDialog::setMode().
00304 { insertItem(aindex, QIcon(), atext, auserData); }
| void QComboBox::insertItem | ( | int | index, | |
| const QIcon & | icon, | |||
| const QString & | text, | |||
| const QVariant & | userData = QVariant() | |||
| ) |
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.
Definition at line 1736 of file qcombobox.cpp.
References _q_dataChanged(), _q_rowsInserted(), QObject::connect(), count(), d, Qt::DecorationRole, QObject::disconnect(), Qt::EditRole, QAbstractItemModel::index(), QIcon::isNull(), QString::isNull(), model(), QAbstractItemModel::removeRows(), rootModelIndex(), QAbstractItemModel::setItemData(), SIGNAL, SLOT, QObject::userData(), Qt::UserRole, and values.
01737 { 01738 Q_D(QComboBox); 01739 if (index < 0) 01740 index = 0; 01741 else if (index > count()) 01742 index = count(); 01743 if (index >= d->maxCount) 01744 return; 01745 01746 QModelIndex item; 01747 disconnect(model(), SIGNAL(rowsInserted(QModelIndex,int,int)), 01748 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01749 disconnect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01750 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01751 if (model()->insertRows(index, 1, rootModelIndex())) { 01752 item = model()->index(index, d->modelColumn, rootModelIndex()); 01753 QMap<int, QVariant> values; 01754 if (!text.isNull()) values.insert(Qt::EditRole, text); 01755 if (!icon.isNull()) values.insert(Qt::DecorationRole, icon); 01756 if (!userData.isNull()) values.insert(Qt::UserRole, userData); 01757 if (!values.isEmpty()) model()->setItemData(item, values); 01758 d->_q_rowsInserted(rootModelIndex(), index, index); 01759 } 01760 connect(model(), SIGNAL(rowsInserted(QModelIndex,int,int)), 01761 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01762 connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01763 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01764 01765 int mc = count(); 01766 if (mc > d->maxCount) 01767 model()->removeRows(mc - 1, mc - d->maxCount, rootModelIndex()); 01768 }
Here is the call graph for this function:

| void QComboBox::insertItems | ( | int | index, | |
| const QStringList & | list | |||
| ) |
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.
Definition at line 1780 of file qcombobox.cpp.
References _q_dataChanged(), _q_rowsInserted(), QList< T >::at(), QObject::connect(), QList< T >::count(), count(), d, QObject::disconnect(), Qt::EditRole, i, index, QList< T >::isEmpty(), model(), qMin(), QAbstractItemModel::removeRows(), rootModelIndex(), QAbstractItemModel::setData(), SIGNAL, and SLOT.
01781 { 01782 Q_D(QComboBox); 01783 if (list.isEmpty()) 01784 return; 01785 01786 if (index < 0) 01787 index = 0; 01788 else if (index < 0 || index > count()) 01789 index = count(); 01790 01791 int insertCount = qMin(d->maxCount - index, list.count()); 01792 if (insertCount <= 0) 01793 return; 01794 disconnect(model(), SIGNAL(rowsInserted(QModelIndex,int,int)), 01795 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01796 disconnect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01797 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01798 if (model()->insertRows(index, insertCount, rootModelIndex())) { 01799 QModelIndex item; 01800 for (int i = 0; i < insertCount; ++i) { 01801 item = model()->index(i+index, d->modelColumn, rootModelIndex()); 01802 model()->setData(item, list.at(i), Qt::EditRole); 01803 } 01804 d->_q_rowsInserted(rootModelIndex(), index, index + insertCount - 1); 01805 } 01806 connect(model(), SIGNAL(rowsInserted(QModelIndex,int,int)), 01807 this, SLOT(_q_rowsInserted(QModelIndex,int,int))); 01808 connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), 01809 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); 01810 int mc = count(); 01811 if (mc > d->maxCount) 01812 model()->removeRows(d->maxCount, mc - d->maxCount, rootModelIndex()); 01813 }
Here is the call graph for this function:

| void QComboBox::removeItem | ( | int | index | ) |
Removes the item at the given index from the combobox. This will update the current index if the index is removed.
Definition at line 1819 of file qcombobox.cpp.
References count(), model(), QAbstractItemModel::removeRows(), and rootModelIndex().
Referenced by qdesigner_internal::ResourceEditor::removeCurrentView(), qdesigner_internal::ResourceEditor::removeEmptyComboItem(), and MultiPageWidget::removePage().
01820 { 01821 Q_ASSERT(index >= 0 && index < count()); 01822 model()->removeRows(index, 1, rootModelIndex()); 01823 }
Here is the call graph for this function:

| void QComboBox::setItemText | ( | int | index, | |
| const QString & | text | |||
| ) |
Sets the text for the item on the given index in the combobox.
Definition at line 1828 of file qcombobox.cpp.
References d, Qt::EditRole, QAbstractItemModel::index(), QModelIndex::isValid(), model(), rootModelIndex(), and QAbstractItemModel::setData().
Referenced by qdesigner_internal::ResourceEditor::saveCurrentView(), MultiPageWidget::setPageTitle(), and qdesigner_internal::ResourceEditor::updateQrcPaths().
01829 { 01830 Q_D(const QComboBox); 01831 QModelIndex item = model()->index(index, d->modelColumn, rootModelIndex()); 01832 if (item.isValid()) { 01833 model()->setData(item, text, Qt::EditRole); 01834 } 01835 }
Here is the call graph for this function:

| void QComboBox::setItemIcon | ( | int | index, | |
| const QIcon & | icon | |||
| ) |
Sets the icon for the item on the given index in the combobox.
Definition at line 1840 of file qcombobox.cpp.
References d, Qt::DecorationRole, QAbstractItemModel::index(), QModelIndex::isValid(), model(), rootModelIndex(), and QAbstractItemModel::setData().
01841 { 01842 Q_D(const QComboBox); 01843 QModelIndex item = model()->index(index, d->modelColumn, rootModelIndex()); 01844 if (item.isValid()) { 01845 model()->setData(item, icon, Qt::DecorationRole); 01846 } 01847 }
Here is the call graph for this function:

| void QComboBox::setItemData | ( | int | index, | |
| const QVariant & | value, | |||
| int | role = Qt::UserRole | |||
| ) |
Sets the data role for the item on the given index in the combobox to the specified value.
Definition at line 1853 of file qcombobox.cpp.
References d, QAbstractItemModel::index(), QModelIndex::isValid(), model(), rootModelIndex(), QAbstractItemModel::setData(), and value.
Referenced by qdesigner_internal::ChangeListContentsCommand::changeContents(), QAbstractFormBuilder::loadComboBoxExtraInfo(), and qdesigner_internal::FlagBox::slotActivated().
01854 { 01855 Q_D(const QComboBox); 01856 QModelIndex item = model()->index(index, d->modelColumn, rootModelIndex()); 01857 if (item.isValid()) { 01858 model()->setData(item, value, role); 01859 } 01860 }
Here is the call graph for this function:

| QAbstractItemView * QComboBox::view | ( | ) | const |
Returns the list view used for the combobox popup.
Definition at line 1865 of file qcombobox.cpp.
References d.
Referenced by QAccessibleComboBox::childCount(), qdesigner_internal::BoolProperty::createEditor(), qdesigner_internal::CursorProperty::createEditor(), qdesigner_internal::MapProperty::createEditor(), qdesigner_internal::ListProperty::createEditor(), QFontComboBox::event(), QAccessibleComboBox::indexOfChild(), itemDelegate(), keyPressEvent(), QFontComboBox::QFontComboBox(), setEditable(), setIconSize(), setItemDelegate(), setRootModelIndex(), QFontComboBox::setWritingSystem(), showPopup(), qdesigner_internal::FlagsProperty::updateEditorContents(), and QFontComboBox::writingSystem().
01866 { 01867 Q_D(const QComboBox); 01868 return const_cast<QComboBoxPrivate*>(d)->viewContainer()->itemView(); 01869 }
| void QComboBox::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.
Definition at line 1880 of file qcombobox.cpp.
References d, QAbstractItemView::model(), qWarning(), and QAbstractItemView::setModel().
01881 { 01882 Q_D(QComboBox); 01883 if (!itemView) { 01884 qWarning("QComboBox::setView: cannot set a 0 view"); 01885 return; 01886 } 01887 01888 if (itemView->model() != d->model) 01889 itemView->setModel(d->model); 01890 d->viewContainer()->setItemView(itemView); 01891 }
Here is the call graph for this function:

| QSize QComboBox::sizeHint | ( | ) | const [virtual] |
This implementation caches the size hint to avoid resizing when the contents change dynamically. To invalidate the cached value change the sizeAdjustPolicy.
Reimplemented from QWidget.
Definition at line 1909 of file qcombobox.cpp.
References d.
Referenced by QFontComboBox::sizeHint(), and Q3FileDialog::updateGeometries().
| QSize QComboBox::minimumSizeHint | ( | ) | const [virtual] |
| void QComboBox::showPopup | ( | ) | [virtual] |
Displays the list of items in the combobox. If the list is empty then the no items will be shown.
Definition at line 1919 of file qcombobox.cpp.
References QRect::adjust(), QRect::bottom(), QRect::bottomLeft(), QRect::bottomRight(), QStyle::CC_ComboBox, QItemSelectionModel::ClearAndSelect, count(), currentIndex(), d, QApplication::desktop(), diff(), QAbstractItemView::EnsureVisible, QWidget::height(), QRect::height(), QSize::height(), QAbstractScrollArea::horizontalScrollBar(), QAbstractScrollArea::horizontalScrollBarPolicy(), index, QWidget::inputContext(), QWidget::mapToGlobal(), QAbstractSlider::maximum(), QAbstractSlider::minimum(), model(), QRect::moveBottom(), QRect::moveBottomLeft(), QRect::moveLeft(), QRect::moveTop(), QRect::moveTopLeft(), QStyle::pixelMetric(), QStyle::PM_DefaultFrameWidth, QAbstractItemView::PositionAtCenter, qMin(), QWidget::raise(), QRect::right(), rootModelIndex(), QStyle::SC_ComboBoxListBoxPopup, Qt::ScrollBarAlwaysOn, Qt::ScrollBarAsNeeded, QAbstractItemView::scrollTo(), QAbstractItemView::selectionModel(), QItemSelectionModel::setCurrentIndex(), QWidget::setFocus(), QWidget::setGeometry(), QRect::setHeight(), QRect::setWidth(), QPoint::setX(), QStyle::SH_ComboBox_Popup, QWidget::show(), QAbstractItemView::sizeHintForIndex(), QComboBoxPrivateContainer::spacing(), QWidget::style(), styleHint(), QRect::top(), QRect::topLeft(), QComboBoxPrivateContainer::updateScrollers(), view(), QAbstractItemView::visualRect(), QRect::width(), QWidget::width(), QRect::x(), QPoint::x(), QWidget::x(), QRect::y(), and QPoint::y().
Referenced by QAccessibleComboBox::doAction(), keyPressEvent(), and mousePressEvent().
01920 { 01921 Q_D(QComboBox); 01922 if (count() <= 0) 01923 return; 01924 01925 // set current item and select it 01926 view()->selectionModel()->setCurrentIndex(d->currentIndex, 01927 QItemSelectionModel::ClearAndSelect); 01928 QComboBoxPrivateContainer* container = d->viewContainer(); 01929 // use top item as height for complete listView 01930 int itemHeight = view()->sizeHintForIndex(model()->index(0, d->modelColumn, rootModelIndex())).height() 01931 + container->spacing(); 01932 QStyleOptionComboBox opt = d->getStyleOption(); 01933 QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt, 01934 QStyle::SC_ComboBoxListBoxPopup, this)); 01935 QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this)); 01936 QPoint below = mapToGlobal(listRect.bottomLeft()); 01937 int belowHeight = screen.bottom() - below.y(); 01938 QPoint above = mapToGlobal(listRect.topLeft()); 01939 int aboveHeight = above.y() - screen.y(); 01940 01941 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 01942 listRect.setHeight(itemHeight * count()); 01943 else 01944 listRect.setHeight(itemHeight * qMin(d->maxVisibleItems, count())); 01945 listRect.setHeight(listRect.height() + 2*container->spacing() 01946 + style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this) * 2); 01947 01948 // Make sure the popup is wide enough to display its contents. 01949 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { 01950 const int diff = d->computeWidthHint() - width(); 01951 if (diff > 0) 01952 listRect.setWidth(listRect.width() + diff); 01953 } 01954 01955 // make sure the widget fits on screen 01956 if (listRect.width() > screen.width() ) 01957 listRect.setWidth(screen.width()); 01958 if (mapToGlobal(listRect.bottomRight()).x() > screen.right()) { 01959 below.setX(screen.x() + screen.width() - listRect.width()); 01960 above.setX(screen.x() + screen.width() - listRect.width()); 01961 } 01962 if (mapToGlobal(listRect.topLeft()).x() < screen.x() ) { 01963 below.setX(screen.x()); 01964 above.setX(screen.x()); 01965 } 01966 01967 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { 01968 01969 // Position horizontally. 01970 listRect.moveLeft(above.x()); 01971 01972 // Position vertically so the curently selected item lines up 01973 // with the combo box. 01974 const QRect currentItemRect = view()->visualRect(view()->currentIndex()); 01975 const int offset = listRect.top() - currentItemRect.top(); 01976 listRect.moveTop(above.y() + offset); 01977 01978 // Clamp the listRect height and vertical position so we don't expand outside the 01979 // available screen geometry.This may override the vertical position, but it is more 01980 // important to show as much as possible of the popup. 01981 const int height = qMin(listRect.height(), screen.height()); 01982 listRect.setHeight(height); 01983 if (listRect.top() < screen.top()) 01984 listRect.moveTop(screen.top()); 01985 if (listRect.bottom() > screen.bottom()) 01986 listRect.moveBottom(screen.bottom()); 01987 } else if (listRect.height() <= belowHeight) { 01988 listRect.moveTopLeft(below); 01989 } else if (listRect.height() <= aboveHeight) { 01990 listRect.moveBottomLeft(above); 01991 } else if (belowHeight >= aboveHeight) { 01992 listRect.setHeight(belowHeight); 01993 listRect.moveTopLeft(below); 01994 } else { 01995 listRect.setHeight(aboveHeight); 01996 listRect.moveBottomLeft(above); 01997 } 01998 01999 #ifndef QT_NO_IM 02000 if (QInputContext *qic = inputContext()) 02001 qic->reset(); 02002 #endif 02003 QScrollBar *sb = view()->horizontalScrollBar(); 02004 Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy(); 02005 bool needHorizontalScrollBar = (policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn) 02006 && sb->minimum() < sb->maximum(); 02007 if (needHorizontalScrollBar) { 02008 listRect.adjust(0, 0, 0, sb->height()); 02009 } 02010 container->setGeometry(listRect); 02011 02012 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) 02013 view()->scrollTo(view()->currentIndex(), QAbstractItemView::PositionAtCenter); 02014 else 02015 view()->scrollTo(view()->currentIndex(), QAbstractItemView::EnsureVisible); 02016 02017 container->raise(); 02018 container->show(); 02019 container->updateScrollers(); 02020 view()->setFocus(); 02021 }
Here is the call graph for this function:

| void QComboBox::hidePopup | ( | ) | [virtual] |
Hides the list of items in the combobox if it is currently visible; otherwise this function does nothing.
Definition at line 2027 of file qcombobox.cpp.
References d, QWidget::hasFocus(), and isEditable().
Referenced by changeEvent(), QComboBoxPrivateContainer::eventFilter(), and hideEvent().
02028 { 02029 Q_D(QComboBox); 02030 if (d->container && d->container->isVisible()) 02031 d->container->hide(); 02032 #ifdef QT_KEYPAD_NAVIGATION 02033 if (QApplication::keypadNavigationEnabled() && isEditable() && hasFocus()) 02034 setEditFocus(true); 02035 #endif 02036 }
Here is the call graph for this function:

| bool QComboBox::event | ( | QEvent * | event | ) | [virtual] |
Reimplemented from QWidget.
Definition at line 2178 of file qcombobox.cpp.
References QEvent::ApplicationLayoutDirectionChange, d, QWidget::event(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, QEvent::LayoutDirectionChange, and QEvent::ShortcutOverride.
Referenced by QFontComboBox::event().
02179 { 02180 Q_D(QComboBox); 02181 switch(event->type()) { 02182 case QEvent::LayoutDirectionChange: 02183 case QEvent::ApplicationLayoutDirectionChange: 02184 d->updateLineEditGeometry(); 02185 break; 02186 case QEvent::HoverEnter: 02187 case QEvent::HoverLeave: 02188 case QEvent::HoverMove: 02189 if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) 02190 d->updateHoverControl(he->pos()); 02191 break; 02192 case QEvent::ShortcutOverride: 02193 if (d->lineEdit) 02194 return d->lineEdit->event(event); 02195 break; 02196 #ifdef QT_KEYPAD_NAVIGATION 02197 case QEvent::EnterEditFocus: 02198 if (!d->lineEdit) 02199 setEditFocus(false); // We never want edit focus if we are not editable 02200 break; 02201 #endif 02202 default: 02203 break; 02204 } 02205 return QWidget::event(event); 02206 }
Here is the call graph for this function:

| void QComboBox::clear | ( | ) | [slot] |
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.
Definition at line 2044 of file qcombobox.cpp.
References model(), QAbstractItemModel::removeRows(), and rootModelIndex().
Referenced by qdesigner_internal::ChangeListContentsCommand::changeContents(), MainWindow::findSizes(), MainWindow::findStyles(), Q3FileDialog::getExistingDirectory(), qdesigner_internal::GraphicsPropertyEditor::populateCombo(), PreviewForm::setCodecList(), Q3FileDialog::setFilter(), Q3FileDialog::setFilters(), Q3FileDialog::setMode(), qdesigner_internal::ResourceEditor::updateQrcStack(), and Q3ActionPrivate::~Q3ActionPrivate().
02045 { 02046 model()->removeRows(0, model()->rowCount(rootModelIndex()), rootModelIndex()); 02047 }
| void QComboBox::clearEditText | ( | ) | [slot] |
| void QComboBox::setEditText | ( | const QString & | text | ) | [slot] |
| void QComboBox::setCurrentIndex | ( | int | index | ) | [slot] |
Definition at line 1648 of file qcombobox.cpp.
References d, QAbstractItemModel::index(), itemText(), model(), rootModelIndex(), and QWidget::update().
Referenced by TrPreviewTool::addTranslator(), FindFileDialog::browse(), Window::browse(), qdesigner_internal::InlineEditor::checkSelection(), qdesigner_internal::FlagsProperty::createEditor(), Window::createMessageGroupBox(), MainWindow::findSizes(), MainWindow::findStyles(), TextEdit::fontChanged(), QInputDialog::getItem(), Window::iconActivated(), qdesigner_internal::ResourceEditor::insertEmptyComboItem(), keyPressEvent(), QAbstractFormBuilder::loadComboBoxExtraInfo(), TrPreviewTool::loadTranslation(), LocationDialog::LocationDialog(), qdesigner_internal::GraphicsPropertyEditor::populateCombo(), SpreadSheet::runInputDialog(), qdesigner_internal::ResourceEditor::saveCurrentView(), MultiPageWidget::setCurrentIndex(), qdesigner_internal::ResourceEditor::setCurrentIndex(), PPDOptionsEditor::setEditorData(), ImageDelegate::setEditorData(), qdesigner_internal::GraphicsPropertyEditor::setIcon(), setModel(), qdesigner_internal::GraphicsPropertyEditor::setPixmap(), qdesigner_internal::InlineEditor::setText(), QFileDialogPrivate::setup(), TextEdit::setupTextActions(), TrPreviewTool::translationSelected(), qdesigner_internal::RichTextEditorToolBar::updateActions(), QFileDialogPrivate::updateButtons(), wheelEvent(), and Window::Window().
01649 { 01650 Q_D(QComboBox); 01651 QModelIndex mi = model()->index(index, d->modelColumn, rootModelIndex()); 01652 01653 bool indexChanged = (mi != d->currentIndex); 01654 if (indexChanged) 01655 d->currentIndex = QPersistentModelIndex(mi); 01656 if (d->lineEdit && d->lineEdit->text() != itemText(d->currentIndex.row())) { 01657 d->lineEdit->setText(itemText(d->currentIndex.row())); 01658 d->updateLineEditGeometry(); 01659 } 01660 if (indexChanged) { 01661 update(); 01662 d->_q_emitCurrentIndexChanged(d->currentIndex.row()); 01663 } 01664 }
| void QComboBox::editTextChanged | ( | const QString & | text | ) | [signal] |
This signal is emitted when the text in the combobox's line edit widget is changed. The new text is specified by text.
Referenced by setLineEdit().
| void QComboBox::activated | ( | int | index | ) | [signal] |
This signal is sent when an item in the combobox is activated by the user. The item's index is given.
Referenced by qdesigner_internal::FlagBox::FlagBox(), and qdesigner_internal::InlineEditor::InlineEditor().
| void QComboBox::activated | ( | const QString & | text | ) | [signal] |
This signal is sent when an item in the combobox is activated by the user. The item's text is given.
| void QComboBox::highlighted | ( | int | index | ) | [signal] |
This signal is sent when an item in the combobox popup list is highlighted by the user. The item's index is given.
| void QComboBox::highlighted | ( | const QString & | text | ) | [signal] |
This signal is sent when an item in the combobox popup list is highlighted by the user. The item's text is given.
| void QComboBox::currentIndexChanged | ( | int | index | ) | [signal] |
Referenced by QFontComboBox::QFontComboBox().
| void QComboBox::currentIndexChanged | ( | const QString & | text | ) | [signal] |
| void QComboBox::focusInEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2078 of file qcombobox.cpp.
References d, and QWidget::update().
02079 { 02080 Q_D(QComboBox); 02081 update(); 02082 if (d->lineEdit) 02083 d->lineEdit->event(e); 02084 }
| void QComboBox::focusOutEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2089 of file qcombobox.cpp.
References d, and QWidget::update().
02090 { 02091 Q_D(QComboBox); 02092 update(); 02093 if (d->lineEdit) 02094 d->lineEdit->event(e); 02095 }
| void QComboBox::changeEvent | ( | QEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2098 of file qcombobox.cpp.
References QWidget::changeEvent(), d, QEvent::EnabledChange, QWidget::font(), QEvent::FontChange, hidePopup(), QWidget::isEnabled(), QWidget::palette(), QEvent::PaletteChange, QEvent::StyleChange, and QEvent::type().
02099 { 02100 Q_D(QComboBox); 02101 switch (e->type()) { 02102 case QEvent::StyleChange: 02103 d->sizeHint = QSize(); // invalidate size hint 02104 if (d->lineEdit) 02105 d->updateLineEditGeometry(); 02106 //### need to update scrollers etc. as well here 02107 break; 02108 case QEvent::EnabledChange: 02109 if (!isEnabled()) 02110 hidePopup(); 02111 break; 02112 case QEvent::PaletteChange: 02113 d->viewContainer()->setPalette(palette()); 02114 break; 02115 case QEvent::FontChange: 02116 d->sizeHint = QSize(); // invalidate size hint 02117 d->viewContainer()->setFont(font()); 02118 if (d->lineEdit) 02119 d->updateLineEditGeometry(); 02120 break; 02121 default: 02122 break; 02123 } 02124 QWidget::changeEvent(e); 02125 }
Here is the call graph for this function:

| void QComboBox::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
| void QComboBox::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2139 of file qcombobox.cpp.
References QStyle::CC_ComboBox, QStyle::CE_ComboBoxLabel, d, QStylePainter::drawComplexControl(), QStylePainter::drawControl(), QWidget::palette(), QPainter::setPen(), and QPalette::Text.
02140 { 02141 Q_D(QComboBox); 02142 QStylePainter painter(this); 02143 painter.setPen(palette().color(QPalette::Text)); 02144 02145 // draw the combobox frame, focusrect and selected etc. 02146 QStyleOptionComboBox opt = d->getStyleOption(); 02147 painter.drawComplexControl(QStyle::CC_ComboBox, opt); 02148 02149 // draw the icon and text 02150 painter.drawControl(QStyle::CE_ComboBoxLabel, opt); 02151 }
Here is the call graph for this function:

| void QComboBox::showEvent | ( | QShowEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2156 of file qcombobox.cpp.
References AdjustToContentsOnFirstShow, d, QWidget::showEvent(), and QWidget::updateGeometry().
02157 { 02158 Q_D(QComboBox); 02159 if (!d->shownOnce && d->sizeAdjustPolicy == QComboBox::AdjustToContentsOnFirstShow) { 02160 d->sizeHint = QSize(); 02161 updateGeometry(); 02162 } 02163 d->shownOnce = true; 02164 QWidget::showEvent(e); 02165 }
Here is the call graph for this function:

| void QComboBox::hideEvent | ( | QHideEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2170 of file qcombobox.cpp.
References hidePopup().
02171 { 02172 hidePopup(); 02173 }
Here is the call graph for this function:

| void QComboBox::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2211 of file qcombobox.cpp.
References QStyle::CC_ComboBox, d, QApplication::doubleClickInterval(), QStyle::hitTestComplexControl(), isEditable(), QMouseEvent::pos(), QStyle::SC_ComboBoxArrow, showPopup(), QStyle::State_Sunken, and QWidget::style().
02212 { 02213 Q_D(QComboBox); 02214 QStyleOptionComboBox opt = d->getStyleOption(); 02215 QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), 02216 this); 02217 if ((sc == QStyle::SC_ComboBoxArrow || !isEditable()) 02218 && !d->viewContainer()->isVisible()) { 02219 if (sc == QStyle::SC_ComboBoxArrow) 02220 d->updateArrow(QStyle::State_Sunken); 02221 d->viewContainer()->blockMouseReleaseTimer.start(QApplication::doubleClickInterval()); 02222 d->viewContainer()->initialClickPosition = e->pos(); 02223 showPopup(); 02224 } 02225 }
Here is the call graph for this function:

| void QComboBox::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2230 of file qcombobox.cpp.
References d, and QStyle::State_None.
02231 { 02232 Q_D(QComboBox); 02233 Q_UNUSED(e); 02234 d->updateArrow(QStyle::State_None); 02235 }
| void QComboBox::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2240 of file qcombobox.cpp.
References Qt::AltModifier, Qt::ControlModifier, count(), QAbstractItemView::currentIndex(), currentIndex(), d, flags, QEvent::ignore(), index, QString::isEmpty(), Qt::ItemIsEnabled, QKeyEvent::key(), Qt::Key_Back, Qt::Key_Down, Qt::Key_End, Qt::Key_Enter, Qt::Key_Escape, Qt::Key_F4, Qt::Key_Home, Qt::Key_Left, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_Return, Qt::Key_Right, Qt::Key_Select, Qt::Key_Space, Qt::Key_Up, QAbstractItemView::keyboardSearch(), model(), QKeyEvent::modifiers(), QWidget::move(), rootModelIndex(), QModelIndex::row(), row, QAbstractItemView::setCurrentIndex(), setCurrentIndex(), showPopup(), QKeyEvent::text(), and view().
02241 { 02242 Q_D(QComboBox); 02243 02244 #ifndef QT_NO_COMPLETER 02245 if (d->lineEdit && d->lineEdit->completer() && d->lineEdit->completer()->popup()->isVisible()) { 02246 // provide same autocompletion support as line edit 02247 d->lineEdit->event(e); 02248 return; 02249 } 02250 #endif 02251 02252 enum Move { NoMove=0 , MoveUp , MoveDown , MoveFirst , MoveLast}; 02253 02254 Move move = NoMove; 02255 int newIndex = currentIndex(); 02256 switch (e->key()) { 02257 case Qt::Key_Up: 02258 if (e->modifiers() & Qt::ControlModifier) 02259 break; // pass to line edit for auto completion 02260 case Qt::Key_PageUp: 02261 #ifdef QT_KEYPAD_NAVIGATION 02262 if (QApplication::keypadNavigationEnabled()) 02263 e->ignore(); 02264 else 02265 #endif 02266 move = MoveUp; 02267 break; 02268 case Qt::Key_Down: 02269 if (e->modifiers() & Qt::AltModifier) { 02270 showPopup(); 02271 return; 02272 } else if (e->modifiers() & Qt::ControlModifier) 02273 break; // pass to line edit for auto completion 02274 // fall through 02275 case Qt::Key_PageDown: 02276 #ifdef QT_KEYPAD_NAVIGATION 02277 if (QApplication::keypadNavigationEnabled()) 02278 e->ignore(); 02279 else 02280 #endif 02281 move = MoveDown; 02282 break; 02283 case Qt::Key_Home: 02284 if (!d->lineEdit) 02285 move = MoveFirst; 02286 break; 02287 case Qt::Key_End: 02288 if (!d->lineEdit) 02289 move = MoveLast; 02290 break; 02291 case Qt::Key_F4: 02292 if (!e->modifiers()) { 02293 showPopup(); 02294 return; 02295 } 02296 break; 02297 case Qt::Key_Space: 02298 if (!d->lineEdit) { 02299 showPopup(); 02300 return; 02301 } 02302 case Qt::Key_Enter: 02303 case Qt::Key_Return: 02304 case Qt::Key_Escape: 02305 if (!d->lineEdit) 02306 e->ignore(); 02307 break; 02308 #ifdef QT_KEYPAD_NAVIGATION 02309 case Qt::Key_Select: 02310 if (QApplication::keypadNavigationEnabled() 02311 && (!hasEditFocus() || !d->lineEdit)) { 02312 showPopup(); 02313 return; 02314 } 02315 break; 02316 case Qt::Key_Left: 02317 if (QApplication::keypadNavigationEnabled() 02318 && (!hasEditFocus() || !d->lineEdit)) 02319 move = MoveUp; 02320 break; 02321 case Qt::Key_Right: 02322 if (QApplication::keypadNavigationEnabled() 02323 && (!hasEditFocus() || !d->lineEdit)) 02324 move = MoveDown; 02325 break; 02326 case Qt::Key_Back: 02327 if (QApplication::keypadNavigationEnabled()) { 02328 if (!hasEditFocus() || !d->lineEdit) 02329 e->ignore(); 02330 } else { 02331 e->ignore(); // let the surounding dialog have it 02332 } 02333 break; 02334 #endif 02335 default: 02336 if (!d->lineEdit && !e->text().isEmpty()) { 02337 // use keyboardSearch from the listView so we do not duplicate code 02338 view()->setCurrentIndex(d->currentIndex); 02339 view()->keyboardSearch(e->text()); 02340 int firstHit = view()->currentIndex().row(); 02341 if (view()->currentIndex().isValid() 02342 && view()->currentIndex() != d->currentIndex) { 02343 do { 02344 newIndex = view()->currentIndex().row(); 02345 if ((view()->currentIndex().flags() & Qt::ItemIsEnabled) && newIndex >= 0 && newIndex < count()) { 02346 setCurrentIndex(newIndex); 02347 d->emitActivated(d->currentIndex); 02348 break; 02349 } 02350 view()->keyboardSearch(e->text()); 02351 } while (view()->currentIndex().isValid() && firstHit != view()->currentIndex().row()); 02352 } 02353 } 02354 } 02355 02356 if (move != NoMove) { 02357 switch (move) { 02358 case MoveFirst: 02359 newIndex = -1; 02360 case MoveDown: 02361 newIndex++; 02362 while ((newIndex < count()) && !(model()->flags(model()->index(newIndex,d->modelColumn,rootModelIndex())) & Qt::ItemIsEnabled)) 02363 newIndex++; 02364 break; 02365 case MoveLast: 02366 newIndex = count(); 02367 case MoveUp: 02368 newIndex--; 02369 while ((newIndex >= 0) && !(model()->flags(model()->index(newIndex,d->modelColumn,rootModelIndex())) & Qt::ItemIsEnabled)) 02370 newIndex--; 02371 break; 02372 default: 02373 break; 02374 } 02375 02376 if (newIndex >= 0 && newIndex < count() && newIndex != currentIndex()) { 02377 setCurrentIndex(newIndex); 02378 d->emitActivated(d->currentIndex); 02379 } 02380 } else if (d->lineEdit) { 02381 d->lineEdit->event(e); 02382 } 02383 }
Here is the call graph for this function:

| void QComboBox::keyReleaseEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
| void QComboBox::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2400 of file qcombobox.cpp.
References QEvent::accept(), count(), currentIndex(), d, QWheelEvent::delta(), flags, index, Qt::ItemIsEnabled, model(), rootModelIndex(), and setCurrentIndex().
02401 { 02402 Q_D(QComboBox); 02403 if (!d->viewContainer()->isVisible()) { 02404 int newIndex = currentIndex(); 02405 02406 if (e->delta() > 0) { 02407 newIndex--; 02408 while ((newIndex >= 0) && !(model()->flags(model()->index(newIndex,d->modelColumn,rootModelIndex())) & Qt::ItemIsEnabled)) 02409 newIndex--; 02410 } else { 02411 newIndex++; 02412 while ((newIndex < count()) && !(model()->flags(model()->index(newIndex,d->modelColumn,rootModelIndex())) & Qt::ItemIsEnabled)) 02413 newIndex++; 02414 } 02415 02416 if (newIndex >= 0 && newIndex < count() && newIndex != currentIndex()) { 02417 setCurrentIndex(newIndex); 02418 d->emitActivated(d->currentIndex); 02419 } 02420 e->accept(); 02421 } 02422 }
Here is the call graph for this function:

| void QComboBox::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2428 of file qcombobox.cpp.
References d, Qt::DefaultContextMenu, and p.
02429 { 02430 Q_D(QComboBox); 02431 if (d->lineEdit) { 02432 Qt::ContextMenuPolicy p = d->lineEdit->contextMenuPolicy(); 02433 d->lineEdit->setContextMenuPolicy(Qt::DefaultContextMenu); 02434 d->lineEdit->event(e); 02435 d->lineEdit->setContextMenuPolicy(p); 02436 } 02437 }
| void QComboBox::inputMethodEvent | ( | QInputMethodEvent * | e | ) | [protected, virtual] |
| QVariant QComboBox::inputMethodQuery | ( | Qt::InputMethodQuery | query | ) | const [protected, virtual] |
Reimplemented from QWidget.
Definition at line 2452 of file qcombobox.cpp.
References d, and QWidget::inputMethodQuery().
02453 { 02454 Q_D(const QComboBox); 02455 if (d->lineEdit) 02456 return d->lineEdit->inputMethodQuery(query); 02457 return QWidget::inputMethodQuery(query); 02458 }
Here is the call graph for this function:

| QComboBox::Q_PRIVATE_SLOT | ( | d_func() | , | |
| void | _q_itemSelected(const QModelIndex &item) | |||
| ) | [private] |
| void QComboBox::_q_emitHighlighted | ( | const QModelIndex & | ) | [private] |
| void void QComboBox::_q_emitCurrentIndexChanged | ( | int | index | ) | [private] |
| void void void QComboBox::_q_returnPressed | ( | ) | [private] |
Referenced by setLineEdit().
| void void void void QComboBox::_q_resetButton | ( | ) | [private] |
| void void void void void QComboBox::_q_dataChanged | ( | const QModelIndex & | , | |
| const QModelIndex & | ||||
| ) | [private] |
Referenced by insertItem(), insertItems(), and setModel().
| void void void void void void QComboBox::_q_rowsAboutToBeInserted | ( | const QModelIndex & | parent, | |
| int | start, | |||
| int | end | |||
| ) | [private] |
Referenced by setModel().
| void void void void void void void QComboBox::_q_rowsInserted | ( | const QModelIndex & | parent, | |
| int | start, | |||
| int | end | |||
| ) | [private] |
Referenced by insertItem(), insertItems(), and setModel().
| void void void void void void void void QComboBox::_q_rowsAboutToBeRemoved | ( | const QModelIndex & | parent, | |
| int | start, | |||
| int | end | |||
| ) | [private] |
Referenced by setModel().
| void void void void void void void void void QComboBox::_q_rowsRemoved | ( | const QModelIndex & | parent, | |
| int | start, | |||
| int | end | |||
| ) | [private] |
Referenced by setModel().
| void void void void void void void void void void QComboBox::_q_modelDestroyed | ( | ) | [private] |
Referenced by setModel(), and ~QComboBox().
1.5.1