mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Доделал Мессенджер
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "msgwidget.h"
|
||||
#include "ui_msgwidget.h"
|
||||
#include <QSizePolicy>
|
||||
|
||||
MsgWidget::MsgWidget(QString avatar, AligneAvatar aligneAvatar, int width, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -72,19 +71,22 @@ void MsgWidget::on_textEdit_textChanged()
|
||||
{
|
||||
QString text = ui->textEdit->toPlainText();
|
||||
QFontMetrics metricsFont(ui->textEdit->font()); //метрики шрифта
|
||||
QRect textRect = metricsFont.boundingRect(QRect(0, 0, 0, 0), 0, text); //геометрические параметры текста (высота/ширина в пикселях)
|
||||
|
||||
//геометрические параметры текста (высота/ширина в пикселях). В одну строку
|
||||
QRect textRect = metricsFont.boundingRect(QRect(0, 0, 0, 0), 0, text);
|
||||
|
||||
int X = 10; // отступы
|
||||
|
||||
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);
|
||||
ui->textEdit->setFixedHeight(textRect.height() + X);
|
||||
this->setFixedHeight(textRect.height() + X + 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->textEdit->setFixedWidth(textRect.width()+X);
|
||||
ui->textEdit->setFixedHeight(textRect.height()+X);
|
||||
this->setFixedHeight(textRect.height()+X + 20);
|
||||
{//В одну строку
|
||||
ui->textEdit->setFixedWidth(textRect.width() + X);
|
||||
ui->textEdit->setFixedHeight(textRect.height() + X);
|
||||
this->setFixedHeight(textRect.height() + X + 20);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user