diff options
author | Marco Martin <mart@kde.org> | 2014-10-27 17:24:11 +0100 |
---|---|---|
committer | Marco Martin <mart@kde.org> | 2014-11-04 12:05:09 +0100 |
commit | 04ec29f8b3abea2297a1f5c033bef49ba0405c34 (patch) | |
tree | 0b9ea0de7ae077df0228cd157a23cb1e359f73d9 /src | |
parent | c81870d244c432633866e442df6343be886d7549 (diff) | |
download | qtquickcontrols-04ec29f8b3abea2297a1f5c033bef49ba0405c34.tar.gz |
Correct sizing of combobox items
The qstyle can set as preferred size for itemview items a different
size than the text height depending from the result of
sizeFromContents( CT_ItemViewItem, ..
Examples of styles that do this, are Oxygen and Breeze,
in order to have a bit more spacing.
This makes the combobox render incorrectly.
This patch makes use of the size hint of the qstyle instead of the
text height. Since the height can be more than the font height,
the text (and optional icon) are now drawn vertically centered
in the delegate.
Change-Id: I898d85c994d5760979750c2f3a5dafd83f1e3cbd
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/Private/qquickstyleitem.cpp | 2 | ||||
-rw-r--r-- | src/controls/Styles/Desktop/ComboBoxStyle.qml | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index edb33212..fb49e6e3 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -354,6 +354,8 @@ void QQuickStyleItem::initStyleOption() opt->features = QStyleOptionViewItem::HasDisplay; opt->text = text(); opt->textElideMode = Qt::ElideRight; + opt->displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; + opt->decorationAlignment = Qt::AlignCenter; resolvePalette(); needsResolvePalette = false; QPalette pal = m_styleoption->palette; diff --git a/src/controls/Styles/Desktop/ComboBoxStyle.qml b/src/controls/Styles/Desktop/ComboBoxStyle.qml index d897a2a4..758518ed 100644 --- a/src/controls/Styles/Desktop/ComboBoxStyle.qml +++ b/src/controls/Styles/Desktop/ComboBoxStyle.qml @@ -109,8 +109,8 @@ Style { elementType: "itemrow" selected: styleData.selected - implicitWidth: textItem.contentWidth - implicitHeight: textItem.contentHeight + implicitWidth: textItem.implicitWidth + implicitHeight: textItem.implicitHeight StyleItem { id: textItem |