summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2014-01-21 18:17:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 11:12:56 +0100
commit3b42b81bc8c7af109aad135f51cc4377a8acd14a (patch)
treeeaec801e85f389dc59b8d96e75ab6717ad554355
parent0e59f0ecd94988f94c2b8e5a6ffd230e220ba273 (diff)
downloadqtquickcontrols-3b42b81bc8c7af109aad135f51cc4377a8acd14a.tar.gz
Fix implicit width for SpinBox
This patch ensures that we take the minimum width of the SpinBox into account when getting the size from the style item. The patch still relies on the height of the TextField since we want to ensure that they keep similar height and the existing spinbox code behaves somewhat erratic. Task-number: QTBUG-36283 Change-Id: I50d14e5afb2576548c381e7f70063dfcb727e7d6 [ChangeLog][QtQuickControls]Fixed implicit width for SpinBox Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r--src/controls/Private/qquickstyleitem.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index c290bc28..d45f4e7b 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -601,6 +601,7 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionSpinBox *opt = qstyleoption_cast<QStyleOptionSpinBox*>(m_styleoption);
opt->frame = true;
+ opt->subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField;
if (value() & 0x1)
opt->activeSubControls = QStyle::SC_SpinBoxUp;
else if (value() & (1<<1))
@@ -919,6 +920,9 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
frame.rect = m_styleoption->rect;
frame.styleObject = this;
size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, &frame, QSize(width, height));
+ if (m_itemType == SpinBox)
+ size.setWidth(qApp->style()->sizeFromContents(QStyle::CT_SpinBox,
+ m_styleoption, QSize(width + 2, height)).width());
}
break;
case GroupBox: {