summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r--src/widgets/widgets/qcombobox.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 9afb4b3ae6..7d4498af5b 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -312,7 +312,7 @@ int QComboBoxPrivate::computeWidthHint() const
const QFontMetrics &fontMetrics = q->fontMetrics();
for (int i = 0; i < count; ++i) {
- const int textWidth = fontMetrics.width(q->itemText(i));
+ const int textWidth = fontMetrics.horizontalAdvance(q->itemText(i));
if (q->itemIcon(i).isNull())
width = (qMax(width, textWidth));
else
@@ -341,7 +341,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
case QComboBox::AdjustToContents:
case QComboBox::AdjustToContentsOnFirstShow:
if (count == 0) {
- sh.rwidth() = 7 * fm.width(QLatin1Char('x'));
+ sh.rwidth() = 7 * fm.horizontalAdvance(QLatin1Char('x'));
} else {
for (int i = 0; i < count; ++i) {
if (!q->itemIcon(i).isNull()) {
@@ -364,7 +364,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
hasIcon = !q->itemIcon(i).isNull();
}
if (minimumContentsLength > 0)
- sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
+ sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
// height
@@ -3215,7 +3215,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
case Qt::Key_Up:
if (e->modifiers() & Qt::ControlModifier)
break; // pass to line edit for auto completion
- // fall through
+ Q_FALLTHROUGH();
case Qt::Key_PageUp:
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
@@ -3303,7 +3303,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
switch (move) {
case MoveFirst:
newIndex = -1;
- // fall through
+ Q_FALLTHROUGH();
case MoveDown:
newIndex++;
while (newIndex < rowCount && !(d->model->index(newIndex, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled))
@@ -3311,7 +3311,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
break;
case MoveLast:
newIndex = rowCount;
- // fall through
+ Q_FALLTHROUGH();
case MoveUp:
newIndex--;
while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled))
@@ -3350,11 +3350,11 @@ void QComboBox::keyReleaseEvent(QKeyEvent *e)
#if QT_CONFIG(wheelevent)
void QComboBox::wheelEvent(QWheelEvent *e)
{
-#ifdef Q_OS_DARWIN
- Q_UNUSED(e);
-#else
Q_D(QComboBox);
- if (!d->viewContainer()->isVisible()) {
+ QStyleOptionComboBox opt;
+ initStyleOption(&opt);
+ if (style()->styleHint(QStyle::SH_ComboBox_AllowWheelScrolling, &opt, this) &&
+ !d->viewContainer()->isVisible()) {
const int rowCount = count();
int newIndex = currentIndex();
@@ -3374,7 +3374,6 @@ void QComboBox::wheelEvent(QWheelEvent *e)
}
e->accept();
}
-#endif
}
#endif