diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 038b0bdcd0c..871c0163c90 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -477,15 +477,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - // let the editor take up all available space - //if the editor is not a QLineEdit - //or it is in a QTableView -#if QT_CONFIG(tableview) && QT_CONFIG(lineedit) - if (qobject_cast(editor) && !qobject_cast(widget)) - opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor); - else -#endif - opt.showDecorationSelected = true; + opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor); QStyle *style = widget ? widget->style() : QApplication::style(); QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 3fca57a03f9..a2810737caa 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1160,12 +1160,8 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect checkRect->size(), check); *pixmapRect = QStyle::alignedRect(opt->direction, opt->decorationAlignment, pixmapRect->size(), decoration); - // the text takes up all available space, unless the decoration is not shown as selected - if (opt->showDecorationSelected) - *textRect = display; - else - *textRect = QStyle::alignedRect(opt->direction, opt->displayAlignment, - textRect->size().boundedTo(display.size()), display); + // the textRect takes up all remaining size + *textRect = display; } else { *checkRect = check; *pixmapRect = decoration;