add recent session message

This commit is contained in:
xyz
2025-06-17 18:40:02 +08:00
parent e4ec73b510
commit c50f574eed
9 changed files with 423 additions and 7 deletions

View File

@ -2,6 +2,7 @@
#include "mainwidget.h"
#include "userinfowidget.h"
#include <qtimer.h>
MessageShowArea::MessageShowArea() {
//初始化基本属性
@ -79,6 +80,25 @@ void MessageShowArea::clear()
}
}
void MessageShowArea::scrollToEnd()
{
//拿到滚动区域的滚动条
//获取到滚动条的最大值并设置
//为了使滚动到正确的位置,即能够在界面绘制好后进行滚动设置
//这里选择给滚动条加个延时
QTimer* timer = new QTimer();
connect(timer, &QTimer::timeout, this, [=]() {
//获取到垂直滚动条的最大值
int maxValue = this->verticalScrollBar()->maximum();
//设置滚动条滚动的位置
this->verticalScrollBar()->setValue(maxValue);
timer->stop();
timer->deleteLater();
});
timer->start(500);
}
////////////////////////////////////////////
/// 表示一个消息元素
////////////////////////////////////////////