Skip to content

Commit

Permalink
QStyledItemDelegate: adjust editor geometry also in LTR-mode
Browse files Browse the repository at this point in the history
The editor geometry was adjusted to a proper size in RTL-mode, but not
in LTR-mode. To fix this inconsistency, the geometry is now also
adjusted in LTR-mode to make sure the editor has enough space for the
min/max values for the given datatype.

Task-number: QTBUG-37433
Change-Id: Iff41e854f2fa2104ab5c589d24780facc3ed5815
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
chehrlic committed Jan 6, 2018
1 parent 20604ea commit 3ed91da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/widgets/itemviews/qstyleditemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,13 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,

QStyle *style = widget ? widget->style() : QApplication::style();
QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget);
if ( editor->layoutDirection() == Qt::RightToLeft) {
const int delta = qSmartMinSize(editor).width() - geom.width();
if (delta > 0) {
//we need to widen the geometry
const int delta = qSmartMinSize(editor).width() - geom.width();
if (delta > 0) {
//we need to widen the geometry
if (editor->layoutDirection() == Qt::RightToLeft)
geom.adjust(-delta, 0, 0, 0);
}
else
geom.adjust(0, 0, delta, 0);
}

editor->setGeometry(geom);
Expand Down

0 comments on commit 3ed91da

Please sign in to comment.