127 const QStyleOptionViewItem&
option,
128 const QModelIndex&
index)
const
130 if (!qobject_cast<QTextEdit*>(editor))
132 QStyledItemDelegate::updateEditorGeometry(editor,
option,
index);
139 int width = r.width();
140 int height = r.height();
141 if (
auto* textEdit = qobject_cast<QTextEdit*>(editor))
143 const QSizeF docSize = textEdit->document()->size();
144 width = std::max(width,
static_cast<int>(docSize.width()) + 20);
145 height = std::max(height,
static_cast<int>(docSize.height()) + 10);
147 if (
const QWidget* parent = editor->parentWidget())
149 width = std::min(width, parent->width() - r.x());
150 height = std::min(height, parent->height() - r.y());
152 r.setSize(QSize(width, height));
153 editor->setGeometry(r);