From f468f76455c91cf1c5b477ab9348337522b4d9aa Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 6 May 2020 15:41:56 +0200 Subject: Add an option to set the alignment of the text in QComboBox Change-Id: Ic9dca8864643302b2b3ff7dbd86260efdb0ab1d5 Reviewed-by: Volker Hilsheimer Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qcombobox.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets/qcombobox.cpp') 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(alignment.toUInt()); + } option->iconSize = iconSize(); if (d->container && d->container->isVisible()) option->state |= QStyle::State_On; -- cgit v1.2.3