7#include <qpa/qplatformtheme.h>
8#include <qpa/qplatformmenu.h>
12#if QT_CONFIG(tableview)
23#if QT_CONFIG(treeview)
29#if QT_CONFIG(proxymodel)
33#include <private/qguiapplication_p.h>
34#include <private/qhighdpiscaling_p.h>
35#include <private/qapplication_p.h>
36#include <private/qcombobox_p.h>
37#include <private/qabstractitemmodel_p.h>
38#include <private/qabstractscrollarea_p.h>
39#include <private/qlineedit_p.h>
40#if QT_CONFIG(completer)
41#include <private/qcompleter_p.h>
45# include <private/qeffects_p.h>
47#include <private/qstyle_p.h>
48#if QT_CONFIG(accessibility)
59 duplicatesEnabled(
false),
85 menuOption.
palette = resolvedpalette;
112 case QMetaType::QIcon:
115 case QMetaType::QColor: {
138 menuOption.
font = qvariant_cast<QFont>(fontRoleData);
180 pressedIndex =
index.row();
184 if (
index.row() != pressedIndex)
202#if QT_CONFIG(completer)
206#if QT_CONFIG(proxymodel)
207 if (
index.isValid() &&
q->completer()) {
213 row = completerIndex.
row();
216 QAbstractProxyModel *completerProxy = qobject_cast<QAbstractProxyModel *>(
q->completer()->model());
220 QString match =
q->completer()->model()->data(completerIndex).toString();
224 q->setCurrentIndex(
row);
239 q->initStyleOption(&
opt);
240 q->update(
q->rect());
263 bool currentReset =
false;
265 const int rowCount =
q->count();
266 for (
int pos = 0;
pos < rowCount; ++
pos) {
295 q->update(lastHoverRect);
306 q->initStyleOption(&
opt);
324 const int count =
q->count();
325 const int iconWidth =
q->iconSize().width() + 4;
329 const int textWidth =
fontMetrics.horizontalAdvance(
q->itemText(
i));
330 if (
q->itemIcon(
i).isNull())
337 q->initStyleOption(&
opt);
361 if (!
q->itemIcon(
i).isNull()) {
374 for (
int i = 0;
i <
count && !hasIcon; ++
i)
375 hasIcon = !
q->itemIcon(
i).isNull();
391 q->initStyleOption(&
opt);
406 q->initStyleOption(&
opt);
448 &&
mask().isEmpty()) {
501 layout->insertSpacing(0, 0);
508#if QT_CONFIG(scrollbar)
509 if (view->verticalScrollBar())
527#if QT_CONFIG(scrollbar)
536 view->verticalScrollBar()->minimum() < view->verticalScrollBar()->maximum()) {
538 bool needTop = view->verticalScrollBar()->value()
539 > (view->verticalScrollBar()->minimum() +
topMargin());
540 bool needBottom = view->verticalScrollBar()->value()
583 view->removeEventFilter(
this);
584 view->viewport()->removeEventFilter(
this);
585#if QT_CONFIG(scrollbar)
601 view->setParent(
this);
603 qobject_cast<QBoxLayout*>(
layout())->insertWidget(
top ? 2 : 0, view);
605 view->installEventFilter(
this);
606 view->viewport()->installEventFilter(
this);
610#if QT_CONFIG(scrollbar)
616 view->setMouseTracking(
true);
620 view->setLineWidth(0);
622#if QT_CONFIG(scrollbar)
623 connect(view->verticalScrollBar(),
SIGNAL(valueChanged(
int)),
625 connect(view->verticalScrollBar(),
SIGNAL(rangeChanged(
int,
int)),
637 if (
const QListView *lview = qobject_cast<const QListView*>(view))
638 return lview->spacing();
639#if QT_CONFIG(tableview)
640 if (
const QTableView *tview = qobject_cast<const QTableView*>(view))
641 return tview->showGrid() ? 1 : 0;
651 QListView *lview = qobject_cast<QListView*>(view);
654#if QT_CONFIG(tableview)
655 QTableView *tview = qobject_cast<QTableView*>(view);
680 if (bottomSpacer && bottomSpacer != topSpacer)
710 switch (keyEvent->
key()) {
713#ifdef QT_KEYPAD_NAVIGATION
729#if QT_CONFIG(shortcut)
754 maybeIgnoreMouseButtonRelease =
false;
785#if QT_CONFIG(graphicsview)
1016 if (!
q->isEditable())
1026 if (!
q->isEditable())
1068 q->updateGeometry();
1080#if QT_CONFIG(accessibility)
1082 QAccessible::updateAccessibility(&
event);
1096 q->updateGeometry();
1102 q->setCurrentIndex(0);
1124 q->updateGeometry();
1155 q->initStyleOption(&
opt);
1178 if (
q->isEditable())
1206 option->state |=
d->arrowState;
1208 option->activeSubControls =
d->hoverControl;
1211 if (
d->currentIndex.isValid()) {
1212 option->currentIcon =
d->itemIcon(
d->currentIndex);
1215 option->textAlignment =
static_cast<Qt::Alignment
>(
alignment.toUInt());
1218 if (
d->container &&
d->container->isVisible())
1229 q->initStyleOption(&
opt);
1232 if (!
q->itemIcon(
q->currentIndex()).isNull()) {
1233 QRect comboRect(editRect);
1236 editRect.
size(), comboRect);
1245#if QT_CONFIG(completer)
1260#if QT_CONFIG(completer)
1261 const auto *leCompleter =
lineEdit->completer();
1263 if (popup && popup->isVisible()) {
1269 const QModelIndex curIndex = popup->currentIndex();
1272 if (completerIsActive)
1278 q->setCurrentIndex(
index);
1307 q->setCurrentIndex(
index);
1325 q->setItemText(
q->currentIndex(),
text);
1327 index =
q->currentIndex() + 1;
1329 index =
q->currentIndex();
1333 for (
int i = 0;
i <
q->count(); ++
i, ++
index) {
1343 q->setCurrentIndex(
index);
1364 if (!
index.isValid())
1374 if (!
index.isValid())
1389#if QT_CONFIG(accessibility)
1391 QAccessible::updateAccessibility(&
event);
1415 this,
SLOT(_q_modelDestroyed()));
1433 return d->maxVisibleItems;
1440 qWarning(
"QComboBox::setMaxVisibleItems: "
1441 "Invalid max visible items (%d) must be >= 0", maxItems);
1444 d->maxVisibleItems = maxItems;
1456 return d->model->rowCount(
d->root);
1475 qWarning(
"QComboBox::setMaxCount: Invalid count (%d) must be >= 0", max);
1479 const int rowCount =
count();
1481 d->model->removeRows(max, rowCount - max,
d->root);
1504 return d->duplicatesEnabled;
1510 d->duplicatesEnabled =
enable;
1534 return result.first().row();
1551 return d->insertPolicy;
1573 return d->sizeAdjustPolicy;
1579 if (
policy ==
d->sizeAdjustPolicy)
1584 d->adjustComboBoxSize();
1602 return d->minimumContentsLength;
1616 d->adjustComboBoxSize();
1633 if (
d->iconSize.isValid())
1637 return QSize(iconWidth, iconWidth);
1643 if (
size ==
d->iconSize)
1676 if (
d->placeholderText.isEmpty())
1688 return d->placeholderText;
1706 return d->lineEdit !=
nullptr;
1720 q->initStyleOption(&
opt);
1722 if (force || qobject_cast<QComboBoxDelegate *>(
q->itemDelegate()))
1725 if (force || qobject_cast<QComboMenuDelegate *>(
q->itemDelegate()))
1732 if (!
index.isValid())
1751 d->viewContainer()->updateScrollers();
1759 d->viewContainer()->updateScrollers();
1763 d->lineEdit->hide();
1764 d->lineEdit->deleteLater();
1765 d->lineEdit =
nullptr;
1768 d->updateDelegate();
1769 d->updateFocusPolicy();
1771 d->viewContainer()->updateTopBottomMargin();
1788 qWarning(
"QComboBox::setLineEdit: cannot set a 0 line edit");
1792 if (
edit ==
d->lineEdit)
1802 if (
d->lineEdit->parent() !=
this)
1803 d->lineEdit->setParent(
this);
1811 d->lineEdit->setFrame(
false);
1813 d->updateFocusPolicy();
1814 d->lineEdit->setFocusProxy(
this);
1817#if QT_CONFIG(completer)
1819 if (!
d->lineEdit->completer()) {
1825#ifdef QT_KEYPAD_NAVIGATION
1829 if (QApplicationPrivate::keypadNavigationEnabled())
1838 d->updateLayoutDirection();
1839 d->updateLineEditGeometry();
1841 d->lineEdit->show();
1858#ifndef QT_NO_VALIDATOR
1871 d->lineEdit->setValidator(
v);
1883 return d->lineEdit ?
d->lineEdit->validator() :
nullptr;
1887#if QT_CONFIG(completer)
1907 qWarning(
"Setting a QCompleter on non-editable QComboBox is not allowed.");
1910 d->lineEdit->setCompleter(
c);
1928 return d->lineEdit ?
d->lineEdit->completer() :
nullptr;
1961 qWarning(
"QComboBox::setItemDelegate: cannot set a 0 delegate");
1995 qWarning(
"QComboBox::setModel: cannot set a 0 model");
2002#if QT_CONFIG(completer)
2003 if (
d->lineEdit &&
d->lineEdit->completer())
2004 d->lineEdit->completer()->setModel(
model);
2010 this,
SLOT(_q_updateIndexBeforeChange()));
2014 this,
SLOT(_q_updateIndexBeforeChange()));
2018 this,
SLOT(_q_modelDestroyed()));
2020 this,
SLOT(_q_updateIndexBeforeChange()));
2022 this,
SLOT(_q_modelReset()));
2023 if (
d->model->QObject::parent() ==
this)
2032 this,
SLOT(_q_updateIndexBeforeChange()));
2036 this,
SLOT(_q_updateIndexBeforeChange()));
2040 this,
SLOT(_q_modelDestroyed()));
2042 this,
SLOT(_q_updateIndexBeforeChange()));
2044 this,
SLOT(_q_modelReset()));
2047 d->container->itemView()->setModel(
model);
2048 connect(
d->container->itemView()->selectionModel(),
2055 d->trySetValidIndex();
2098 return d->currentIndex.row();
2105 d->setCurrentIndex(mi);
2134#if QT_CONFIG(completer)
2136 lineEdit->completer()->setCompletionPrefix(newText);
2147 if (modelResetToEmpty)
2150 if (indexChanged || modelResetToEmpty) {
2174 return d->lineEdit->text();
2175 if (
d->currentIndex.isValid())
2176 return d->itemText(
d->currentIndex);
2191 return d->currentIndex.data(role);
2201 return d->itemText(mi);
2211 return d->itemIcon(mi);
2222 return d->model->data(mi, role);
2254 int itemCount =
count();
2256 if (
index >=
d->maxCount)
2268 d->inserting =
true;
2269 if (
d->model->insertRows(
index, 1,
d->root)) {
2280 d->inserting =
false;
2284 d->inserting =
false;
2288 if (itemCount >
d->maxCount)
2289 d->model->removeRows(itemCount - 1, itemCount -
d->maxCount,
d->root);
2309 if (insertCount <= 0)
2317 for (
int i = 0;
i < insertCount; ++
i)
2321 d->inserting =
true;
2322 if (
d->model->insertRows(
index, insertCount,
d->root)) {
2324 for (
int i = 0;
i < insertCount; ++
i) {
2328 d->inserting =
false;
2329 d->_q_rowsInserted(
d->root,
index,
index + insertCount - 1);
2331 d->inserting =
false;
2336 if (mc >
d->maxCount)
2337 d->model->removeRows(
d->maxCount, mc -
d->maxCount,
d->root);
2354 int itemCount =
count();
2356 if (
index >=
d->maxCount)
2371 if (index < 0 || index >=
count())
2373 d->model->removeRows(
index, 1,
d->root);
2383 if (
item.isValid()) {
2395 if (
item.isValid()) {
2408 if (
item.isValid()) {
2435 qWarning(
"QComboBox::setView: cannot set a 0 view");
2439 if (itemView->
model() !=
d->model)
2441 d->viewContainer()->setItemView(itemView);
2450 return d->recomputeSizeHint(
d->minimumSizeHint);
2463 return d->recomputeSizeHint(
d->sizeHint);
2467void QComboBoxPrivate::cleanupNativePopup()
2469 if (!m_platformMenu)
2472 int count = int(m_platformMenu->tag());
2474 m_platformMenu->menuItemAt(
i)->deleteLater();
2476 delete m_platformMenu;
2486bool QComboBoxPrivate::showNativePopup()
2490 cleanupNativePopup();
2494 if (!m_platformMenu)
2497 int itemsCount =
q->count();
2503 for (
int i = 0;
i < itemsCount; ++
i) {
2509 const Qt::ItemFlags itemFlags =
model->
flags(rowIndex);
2512 item->setCheckable(
true);
2521 m_platformMenu->insertMenuItem(
item, 0);
2522 m_platformMenu->syncMenuItem(
item);
2525 QWindow *tlw =
q->window()->windowHandle();
2526 m_platformMenu->setFont(
q->font());
2576 &&
d->showNativePopup())
2591 int belowHeight =
screen.bottom() - below.
y();
2593 int aboveHeight = above.
y() -
screen.y();
2601#if QT_CONFIG(treeview)
2603 if (treeView && treeView->
header() && !treeView->
header()->isHidden())
2604 listHeight += treeView->
header()->height();
2613#if QT_CONFIG(treeview)
2614 if (
d->model->hasChildren(idx) && treeView && treeView->
isExpanded(idx))
2618 if (!usePopup &&
count >=
d->maxVisibleItems) {
2652 const int diff =
d->computeWidthHint() -
width();
2664 if (boundToScreen) {
2690 const int offset = listRect.
top() - currentItemRect.
top();
2699 if (boundToScreen) {
2705 }
else if (!boundToScreen || listRect.
height() <= belowHeight) {
2707 }
else if (listRect.
height() <= aboveHeight) {
2709 }
else if (belowHeight >= aboveHeight) {
2722 const auto needHorizontalScrollBar = [
this, sb]{
2727 const bool neededHorizontalScrollBar = needHorizontalScrollBar();
2728 if (neededHorizontalScrollBar)
2741#if QT_CONFIG(effects)
2742 bool scrollDown = (listRect.
topLeft() == below);
2761 QScreen *currentScreen =
d->associatedScreen();
2763 containerWindow->setScreen(currentScreen);
2772 if (!neededHorizontalScrollBar && needHorizontalScrollBar()) {
2791 container->popupTimer.
start();
2792 container->maybeIgnoreMouseButtonRelease =
true;
2811 d->hidingPopup =
true;
2814 d->hidingPopup =
false;
2817 if (!
d->container || !
d->container->isVisible())
2820#if QT_CONFIG(effects)
2822 ?
d->container->itemView()->selectionModel() :
nullptr;
2829 QSignalBlocker modelBlocker(d->model);
2830 QSignalBlocker viewBlocker(d->container->itemView());
2831 QSignalBlocker containerBlocker(d->container);
2834 selectionModel->select(selection, QItemSelectionModel::Toggle);
2835 QTimer::singleShot(60, d->container, [d, selection, selectionModel]{
2836 QSignalBlocker modelBlocker(d->model);
2837 QSignalBlocker viewBlocker(d->container->itemView());
2838 QSignalBlocker containerBlocker(d->container);
2839 selectionModel->select(selection, QItemSelectionModel::Toggle);
2840 QTimer::singleShot(20, d->container, [d] {
2866 emit q_func()->currentTextChanged(
text);
2878 d->model->removeRows(0,
d->model->rowCount(
d->root),
d->root);
2879#if QT_CONFIG(accessibility)
2881 QAccessible::updateAccessibility(&
event);
2892 d->lineEdit->clear();
2893#if QT_CONFIG(accessibility)
2895 QAccessible::updateAccessibility(&
event);
2906 d->lineEdit->setText(
text);
2907#if QT_CONFIG(accessibility)
2908 QAccessibleValueChangeEvent
event(
this,
text);
2909 QAccessible::updateAccessibility(&
event);
2921 d->lineEdit->event(
e);
2922#if QT_CONFIG(completer)
2923 if (
d->lineEdit->completer())
2924 d->lineEdit->completer()->setWidget(
this);
2937 d->lineEdit->event(
e);
2944 switch (
e->type()) {
2947 d->container->updateStyleSettings();
2948 d->updateDelegate();
2953 d->minimumSizeHint =
QSize();
2954 d->updateLayoutDirection();
2956 d->updateLineEditGeometry();
2978 d->updateViewContainerPaletteAndOpacity();
2983 d->viewContainer()->setFont(
font());
2984 d->viewContainer()->itemView()->doItemsLayout();
2986 d->updateLineEditGeometry();
3001 d->updateLineEditGeometry();
3036 d->shownOnce =
true;
3054 switch(
event->type()) {
3057 d->updateLayoutDirection();
3058 d->updateLineEditGeometry();
3064 d->updateHoverControl(he->position().toPoint());
3068 return d->lineEdit->event(
event);
3070#ifdef QT_KEYPAD_NAVIGATION
3071 case QEvent::EnterEditFocus:
3073 d->lineEdit->event(
event);
3075 case QEvent::LeaveEditFocus:
3077 d->lineEdit->event(
event);
3093 d->showPopupFromMouseEvent(
e);
3100 q->initStyleOption(&
opt);
3109#ifdef QT_KEYPAD_NAVIGATION
3128#ifdef QT_KEYPAD_NAVIGATION
3146 d->showPopupFromMouseEvent(
e);
3156#if QT_CONFIG(completer)
3159 if (popup && popup->isVisible()) {
3161 d->lineEdit->event(
e);
3167 enum Move { NoMove=0 , MoveUp , MoveDown , MoveFirst , MoveLast};
3172 bool pressLikeButton = !
d->lineEdit;
3173#ifdef QT_KEYPAD_NAVIGATION
3174 pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
3176 auto key =
e->key();
3177 if (pressLikeButton) {
3181 if (buttonPressKeys.contains(
key)) {
3193#ifdef QT_KEYPAD_NAVIGATION
3194 if (QApplicationPrivate::keypadNavigationEnabled())
3208#ifdef QT_KEYPAD_NAVIGATION
3209 if (QApplicationPrivate::keypadNavigationEnabled())
3224 if (!
e->modifiers()) {
3235#ifdef QT_KEYPAD_NAVIGATION
3238 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
3242 if (QApplicationPrivate::keypadNavigationEnabled()) {
3243 if (!hasEditFocus() || !
d->lineEdit)
3251#if QT_CONFIG(shortcut)
3259 if (!
e->text().isEmpty())
3260 d->keyboardSearchString(
e->text());
3266 const int rowCount =
count();
3268 if (move != NoMove) {
3276 while (newIndex < rowCount && !(
d->model->index(newIndex,
d->modelColumn,
d->root).flags() &
Qt::ItemIsEnabled))
3280 newIndex = rowCount;
3284 while ((newIndex >= 0) && !(
d->model->flags(
d->model->index(newIndex,
d->modelColumn,
d->root)) &
Qt::ItemIsEnabled))
3292 if (newIndex >= 0 && newIndex < rowCount && newIndex !=
currentIndex()) {
3294 d->emitActivated(
d->currentIndex);
3296 }
else if (
d->lineEdit) {
3297 d->lineEdit->event(
e);
3309 d->lineEdit->event(
e);
3317#if QT_CONFIG(wheelevent)
3318void QComboBox::wheelEvent(QWheelEvent *
e)
3322 initStyleOption(&
opt);
3324 !
d->viewContainer()->isVisible()) {
3325 const int rowCount =
count();
3327 int delta =
e->angleDelta().y();
3331 while ((newIndex >= 0) && !(
d->model->flags(
d->model->index(newIndex,
d->modelColumn,
d->root)) &
Qt::ItemIsEnabled))
3333 }
else if (delta < 0) {
3335 while (newIndex < rowCount && !(
d->model->index(newIndex,
d->modelColumn,
d->root).flags() &
Qt::ItemIsEnabled))
3339 if (newIndex >= 0 && newIndex < rowCount && newIndex !=
currentIndex()) {
3341 d->emitActivated(
d->currentIndex);
3348#ifndef QT_NO_CONTEXTMENU
3358 d->lineEdit->event(
e);
3359 d->lineEdit->setContextMenuPolicy(
p);
3369 int currentRow =
view->currentIndex().row();
3371 if (currentRow !=
view->currentIndex().row()) {
3384 q->updateGeometry();
3395 d->lineEdit->event(
e);
3397 if (!
e->commitString().isEmpty())
3398 d->keyboardSearchString(
e->commitString());
3411 return d->lineEdit->inputMethodQuery(
query);
3495 return d->modelColumn;
3501 d->modelColumn = visibleColumn;
3502 QListView *lv = qobject_cast<QListView *>(
d->viewContainer()->itemView());
3505#if QT_CONFIG(completer)
3506 if (
d->lineEdit &&
d->lineEdit->completer())
3507 d->lineEdit->completer()->setCompletionColumn(visibleColumn);
3514#include "moc_qcombobox.cpp"
3515#include "moc_qcombobox_p.cpp"
The QAbstractItemDelegate class is used to display and edit data items from a model.
static QAbstractItemModel * staticEmptyModel()
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
The QAbstractItemView class provides the basic functionality for item view classes.
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
void setEditTriggers(EditTriggers triggers)
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void setTextElideMode(Qt::TextElideMode mode)
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for this view and its model to delegate.
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
void setIconSize(const QSize &size)
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used by this view and model.
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
virtual Q_INVOKABLE QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
QAbstractItemModel * sourceModel
the source model of this proxy model.
SliderAction
\value SliderNoAction \value SliderSingleStepAdd \value SliderSingleStepSub \value SliderPageStepAdd ...
int minimum
the sliders's minimum value
int maximum
the slider's maximum value
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
static QPalette palette()
Returns the current application palette.
int doubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
int timerId() const noexcept
Returns the timer's ID.
void stop()
Stops the timer.
The QBoxLayout class lines up child widgets horizontally or vertically.
void invalidate() override
Resets cached information.
int count() const override
\reimp
QLayoutItem * itemAt(int) const override
\reimp
static bool isSeparator(const QModelIndex &index)
static void setSeparator(QAbstractItemModel *model, const QModelIndex &index)
void updateStyleSettings()
QPoint initialClickPosition
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
QAbstractItemView * itemView() const
QBasicTimer adjustSizeTimer
int spacing() const
Returns the spacing between the items in the view.
void scrollItemView(int action)
void mouseReleaseEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
void showEvent(QShowEvent *e) override
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
void itemSelected(const QModelIndex &)
QTimer blockMouseReleaseTimer
void hideEvent(QHideEvent *e) override
This event handler can be reimplemented in a subclass to receive widget hide events.
int topMargin() const
Returns the top/bottom vertical margin of the view.
void timerEvent(QTimerEvent *timerEvent) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void updateTopBottomMargin()
void setItemView(QAbstractItemView *itemView)
Sets the item view to be used for the combobox popup.
QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent)
void resizeEvent(QResizeEvent *e) override
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
bool eventFilter(QObject *o, QEvent *e) override
Filters events if this object has been installed as an event filter for the watched object.
void changeEvent(QEvent *e) override
This event handler can be reimplemented to handle state changes.
QStyleOptionComboBox comboStyleOption() const
void paintEvent(QPaintEvent *e) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void emitActivated(const QModelIndex &index)
QComboBox::InsertPolicy insertPolicy
QComboBoxPrivateContainer * viewContainer()
QStyle::SubControl hoverControl
void keyboardSearchString(const QString &text)
void updateViewContainerPaletteAndOpacity()
QComboBoxPrivateContainer * container
QPersistentModelIndex currentIndex
QStyle::SubControl newHoverControl(const QPoint &pos)
QIcon itemIcon(const QModelIndex &index) const
QSize recomputeSizeHint(QSize &sh) const
void showPopupFromMouseEvent(QMouseEvent *e)
QPersistentModelIndex root
Qt::MatchFlags matchFlags() const
int computeWidthHint() const
void setCurrentIndex(const QModelIndex &index)
int minimumContentsLength
QRect popupGeometry(const QPoint &globalPos) const
void updateArrow(QStyle::StateFlag state)
QAbstractItemModel * model
void _q_emitCurrentIndexChanged(const QModelIndex &index)
QComboBox::SizeAdjustPolicy sizeAdjustPolicy
QString itemText(const QModelIndex &index) const
void updateDelegate(bool force=false)
void adjustComboBoxSize()
void _q_rowsRemoved(const QModelIndex &parent, int start, int end)
void _q_updateIndexBeforeChange()
QStyle::StateFlag arrowState
void _q_itemSelected(const QModelIndex &item)
bool updateHoverControl(const QPoint &pos)
void updateCurrentText(const QString &text)
void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void _q_editingFinished()
void updateLineEditGeometry()
void _q_emitHighlighted(const QModelIndex &index)
void updateLayoutDirection()
void _q_rowsInserted(const QModelIndex &parent, int start, int end)
The QComboBox widget is a combined button and popup list.
SizeAdjustPolicy sizeAdjustPolicy
the policy describing how the size of the combobox changes when the content changes
void removeItem(int index)
Removes the item at the given index from the combobox.
void showEvent(QShowEvent *e) override
\reimp
InsertPolicy
This enum specifies what the QComboBox should do when a new string is entered by the user.
void setInsertPolicy(InsertPolicy policy)
int maxCount
the maximum number of items allowed in the combobox
QComboBox(QWidget *parent=nullptr)
Constructs a combobox with the given parent, using the default model QStandardItemModel.
void setModelColumn(int visibleColumn)
int modelColumn
the column in the model that is visible.
QLineEdit * lineEdit() const
Returns the line edit used to edit items in the combobox, or \nullptr if there is no line edit.
QString itemText(int index) const
Returns the text for the given index in the combobox.
void setMinimumContentsLength(int characters)
virtual void initStyleOption(QStyleOptionComboBox *option) const
Initialize option with the values from this QComboBox.
int findData(const QVariant &data, int role=Qt::UserRole, Qt::MatchFlags flags=static_cast< Qt::MatchFlags >(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
Returns the index of the item containing the given data for the given role; otherwise returns -1.
void setMaxCount(int max)
void setDuplicatesEnabled(bool enable)
SizeAdjustPolicy
This enum specifies how the size hint of the QComboBox should adjust when new content is added or con...
@ AdjustToMinimumContentsLengthWithIcon
@ AdjustToContentsOnFirstShow
void insertItem(int index, const QString &text, const QVariant &userData=QVariant())
Inserts the text and userData (stored in the Qt::UserRole) into the combobox at the given index.
QAbstractItemView * view() const
Returns the list view used for the combobox popup.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for the popup list view.
void mouseReleaseEvent(QMouseEvent *e) override
\reimp
int minimumContentsLength
the minimum number of characters that should fit into the combobox.
bool editable
whether the combo box can be edited by the user
void activated(int index)
This signal is sent when the user chooses an item in the combobox.
const QValidator * validator() const
Returns the validator that is used to constrain text input for the combobox.
QString placeholderText
Sets a placeholderText text shown when no valid index is set.
int count
the number of items in the combobox
bool event(QEvent *event) override
\reimp
void editTextChanged(const QString &)
This signal is emitted when the text in the combobox's line edit widget is changed.
void currentTextChanged(const QString &)
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used by the popup list view.
virtual void hidePopup()
Hides the list of items in the combobox if it is currently visible and resets the internal state,...
void hideEvent(QHideEvent *e) override
\reimp
InsertPolicy insertPolicy
the policy used to determine where user-inserted items should appear in the combobox
void setMaxVisibleItems(int maxItems)
void insertItems(int index, const QStringList &texts)
Inserts the strings from the list into the combobox as separate items, starting at the index specifie...
void clearEditText()
Clears the contents of the line edit used for editing in the combobox.
virtual void setModel(QAbstractItemModel *model)
Sets the model to be model.
QModelIndex rootModelIndex() const
Returns the root model item index for the items in the combobox.
void inputMethodEvent(QInputMethodEvent *) override
\reimp
void keyPressEvent(QKeyEvent *e) override
\reimp
void setView(QAbstractItemView *itemView)
Sets the view to be used in the combobox popup to the given itemView.
void paintEvent(QPaintEvent *e) override
\reimp
void clear()
Clears the combobox, removing all items.
int maxVisibleItems
the maximum allowed size on screen of the combo box, measured in items
void resizeEvent(QResizeEvent *e) override
\reimp
void setIconSize(const QSize &size)
void keyReleaseEvent(QKeyEvent *e) override
\reimp
QString currentText
the current text
bool duplicatesEnabled
whether the user can enter duplicate items into the combobox
void setEditText(const QString &text)
Sets the text in the combobox's text edit.
void setLineEdit(QLineEdit *edit)
Sets the line edit to use instead of the current line edit widget.
void setRootModelIndex(const QModelIndex &index)
Sets the root model item index for the items in the combobox.
QSize minimumSizeHint() const override
\reimp
QSize sizeHint() const override
\reimp
void setItemIcon(int index, const QIcon &icon)
Sets the icon for the item on the given index in the combobox.
void focusOutEvent(QFocusEvent *e) override
\reimp
QVariant itemData(int index, int role=Qt::UserRole) const
Returns the data for the given role in the given index in the combobox, or an invalid QVariant if the...
void changeEvent(QEvent *e) override
\reimp
void setSizeAdjustPolicy(SizeAdjustPolicy policy)
QAbstractItemModel * model() const
Returns the model used by the combobox.
void insertSeparator(int index)
void mousePressEvent(QMouseEvent *e) override
\reimp
int findText(const QString &text, Qt::MatchFlags flags=static_cast< Qt::MatchFlags >(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
Returns the index of the item containing the given text; otherwise returns -1.
void setItemText(int index, const QString &text)
Sets the text for the item on the given index in the combobox.
void contextMenuEvent(QContextMenuEvent *e) override
\reimp
int currentIndex
the index of the current item in the combobox.
QVariant currentData
the data for the current item
virtual void showPopup()
Displays the list of items in the combobox.
void focusInEvent(QFocusEvent *e) override
\reimp
void 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.
QSize iconSize
the size of the icons shown in the combobox.
void setCurrentText(const QString &text)
QIcon itemIcon(int index) const
Returns the icon for the given index in the combobox.
void setValidator(const QValidator *v)
Sets the validator to use instead of the current validator.
void setEditable(bool editable)
~QComboBox()
Destroys the combobox.
void setPlaceholderText(const QString &placeholderText)
QVariant inputMethodQuery(Qt::InputMethodQuery) const override
\reimp
void setCurrentIndex(int index)
QAbstractItemView * popup
static QCompleterPrivate * get(QCompleter *o)
The QCompleter class provides completions based on an item model.
void setCompletionColumn(int column)
@ UnfilteredPopupCompletion
void setCompletionMode(CompletionMode mode)
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
qint64 elapsed() const noexcept
Returns the number of milliseconds since this QElapsedTimer was last started.
void start() noexcept
Starts this timer.
@ ApplicationLayoutDirectionChange
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
qreal height() const
Returns the height of the font.
\reentrant \inmodule QtGui
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
The QFrame class is the base class of widgets that can have a frame.
void setFrameStyle(int)
Sets the frame style to style.
void paintEvent(QPaintEvent *) override
\reimp
void changeEvent(QEvent *) override
\reimp
void setData(int key, const QVariant &value)
Sets this item's custom data for the key key to value.
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
static QGuiApplicationPrivate * instance()
static QPlatformTheme * platformTheme()
static QStyleHints * styleHints()
Returns the application's style hints.
static QInputMethod * inputMethod()
returns the input method.
T value(const Key &key) const noexcept
The QHideEvent class provides an event which is sent after a widget is hidden.
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
QModelIndexList selectedIndexes
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
int key() const
Returns the code of the key that was pressed or released.
virtual QSpacerItem * spacerItem()
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned.
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
virtual void setSpacing(int)
bool activate()
Redoes the layout for parentWidget() if necessary.
void setContentsMargins(int left, int top, int right, int bottom)
The QLineEdit widget is a one-line text editor.
bool event(QEvent *) override
\reimp
void selectAll()
Selects all the text (i.e.
void end(bool mark)
Moves the text cursor to the end of the line unless it is already there.
void setText(const QString &)
void deselect()
Deselects any selected text.
QString text
the line edit's text.
The QListView class provides a list or icon view onto a model.
int spacing
the space around the items in the layout
void setModelColumn(int column)
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
constexpr int bottom() const noexcept
Returns the bottom margin.
constexpr int top() const noexcept
Returns the top margin.
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
Qt::ItemFlags flags() const
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
static QObjectPrivate * get(QObject *o)
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QPalette class contains color groups for each widget state.
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
const QBrush & placeholderText() const
bool isValid() const
Returns {true} if this persistent model index is valid; otherwise returns {false}.
int row() const
Returns the row this persistent model index refers to.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
constexpr void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
\inmodule QtCore\reentrant
constexpr QPoint bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr void moveTopLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void moveBottom(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void moveLeft(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr void moveBottomLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the bottom-left corner at the given position.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
constexpr void moveTop(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
The QResizeEvent class contains event parameters for resize events.
The QScreen class is used to query screen properties. \inmodule QtGui.
QList< QScreen * > virtualSiblings() const
Get the screen's virtual siblings.
The QShowEvent class provides an event that is sent when a widget is shown.
Qt::MouseButton button() const
Returns the button that caused the event.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr int & rwidth() noexcept
Returns a reference to the width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
The QSpacerItem class provides blank space in a layout.
void changeSize(int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum)
Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolic...
T pop()
Removes the top item from the stack and returns it.
void push(const T &t)
Adds element t to the top of the stack.
The QStandardItemModel class provides a generic model for storing custom data.
The QStandardItem class provides an item for use with the QStandardItemModel class.
void insertRows(int row, const QList< QStandardItem * > &items)
Inserts items at row.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toLower() const &
QChar * data()
Returns a pointer to the data stored in the QString.
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionToolButton::features
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
static bool useFullScreenForPopup()
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
StateFlag
This enum describes flags that are used when drawing primitive elements.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
@ SH_ComboBox_ListMouseTracking
@ SH_ComboBox_UseNativePopup
@ SH_Menu_FlashTriggeredItem
@ SH_ComboBox_PopupFrameStyle
@ SH_ComboBox_LayoutDirection
@ SH_ComboBox_AllowWheelScrolling
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=nullptr) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
SubControl
This enum describes the available sub controls.
@ SC_ComboBoxListBoxPopup
The QTableView class provides a default model/view implementation of a table view.
bool showGrid
whether the grid is shown
void setSingleShot(bool singleShot)
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
bool singleShot
whether the timer is a single-shot timer
void stop()
Stops the timer.
The QTreeView class provides a default model/view implementation of a tree view.
bool isExpanded(const QModelIndex &index) const
Returns true if the model item index is expanded; otherwise returns false.
QHeaderView * header() const
Returns the header for the tree view.
The QValidator class provides validation of input text.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool canConvert(QMetaType targetType) const
void setMinimumWidth(int w)
void textChanged(const QString &newText)
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
T toNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
void setter(QUntypedPropertyData *d, const void *value)
@ WA_X11NetWmWindowTypeCombo
FontHash * qt_app_fonts_hash()
void qScrollEffect(QWidget *w, QEffects::DirFlags orient, int time)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLint GLenum GLboolean normalized
static QPlatformTheme::Font platformFont(QQuickTheme::Scope scope)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
const char className[16]
[1]
QSqlQueryModel * model
[16]
QList< QChar > characters
obj metaObject() -> className()
myObject disconnect()
[26]
QItemSelection * selection
[0]
lineEdit setCompleter(completer)
QCompleter * completer
[0]
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
virtual HRESULT STDMETHODCALLTYPE Move(enum TextUnit unit, int count, __RPC__out int *pRetVal)=0