diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-05-06 15:41:56 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-05-15 05:00:10 +0200 |
commit | f468f76455c91cf1c5b477ab9348337522b4d9aa (patch) | |
tree | 26f18ae1276d2867e2692b434cf3cb4e2449f58a /src/widgets/widgets/qcombobox.cpp | |
parent | 6028e16b8693c8c7403fd4e5341c52beb33e5613 (diff) |
Add an option to set the alignment of the text in QComboBox
Change-Id: Ic9dca8864643302b2b3ff7dbd86260efdb0ab1d5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index a0e04285e9..ba771f7ce9 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1240,8 +1240,12 @@ void QComboBox::initStyleOption(QStyleOptionComboBox *option) const option->activeSubControls = d->hoverControl; } option->currentText = currentText(); - if (d->currentIndex.isValid()) + if (d->currentIndex.isValid()) { option->currentIcon = d->itemIcon(d->currentIndex); + QVariant alignment = d->model->data(d->currentIndex, Qt::TextAlignmentRole); + if (alignment.isValid()) + option->textAlignment = static_cast<Qt::Alignment>(alignment.toUInt()); + } option->iconSize = iconSize(); if (d->container && d->container->isVisible()) option->state |= QStyle::State_On; |