There is a fixed-width QTextEdit . It is necessary that when it is filled with text, it expands upwards, but the scroll bar simply turns on. Many googlin, but did not find anything that helped.
Wrote such a crutch
connect(text_input, &CSTextEdit::textChanged, [this]() { int height = QFontMetrics(text_input->font()) .boundingRect(QRect(), text_input->alignment(), text_input->toPlainText()) .height(); height = height > 47 ? height : 47; text_input->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); text_input->setMaximumHeight(height); }); But it turned out that the line break is only visual and all this text is one line, therefore the height remains unchanged.