mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 00:51:48 +08:00
add recent session message
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
/// 表示一个消息元素
|
||||
////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user