Рефакт

This commit is contained in:
2025-09-10 18:17:47 +03:00
parent 747734a763
commit 33f67c14f1
2 changed files with 25 additions and 7 deletions

View File

@@ -90,9 +90,27 @@ void MsgWidget::on_textEdit_textChanged()
if(textRect.width() > widthEdit)
{//Не помещается в одну строку
textRect = metricsFont.boundingRect(QRect(0, 0, widthEdit, 10), Qt::TextWordWrap, text);
ui->textEdit->setFixedHeight(textRect.height() + X);
this->setFixedHeight(textRect.height() + X + 20 + 30);
textRect = metricsFont.boundingRect(QRect(0, 0, widthEdit, 1000), 0, text);
if(textRect.width() > widthEdit)
{
QRect textRect1str = metricsFont.boundingRect(QRect(0, 0, widthEdit, 1000), 0, "string");
int ost = textRect.width() % widthEdit;
int cnt = textRect.width() / widthEdit;
if(ost > 0)
cnt += 1;
this->setFixedHeight(textRect1str.height() * cnt + (ost? textRect1str.height() : 0) + X + 20 + 30);
ui->textEdit->setFixedHeight(textRect1str.height() * cnt + (ost? textRect1str.height() : 0) + X);
}
else
{
this->setFixedHeight(textRect.height() + X + 20 + 30);
ui->textEdit->setFixedHeight(textRect.height() + X);
}
}
else
{//В одну строку