Files
MyChat_Client/sessionfriendarea.cpp
2025-05-21 19:01:38 +08:00

41 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "sessionfriendarea.h"
#include <QScrollBar>
#include <QVBoxLayout>
#include <QPushButton>
SessionFriendArea::SessionFriendArea(QWidget *parent)
: QScrollArea {parent}
{
//设置必要属性
//设置这个才能有滚动效果
this->setWidgetResizable(true);
//设置滚动条相关样式
this->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 2px; background-color: rgb(46, 46, 46); }");
this->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal { height: 0px; }");
// 把widget创建出来
container = new QWidget();
container->setFixedWidth(310);
this->setWidget(container);
//给这个widget添加布局管理器方便后续添加元素进去
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->setAlignment(Qt::AlignTop);
container->setLayout(layout);
// //简单测试一下滚动的效果(just for testing...)
// for(int i = 0; i < 50; i++) {
// QPushButton* btn = new QPushButton();
// QString Sbtn = "button: " + QString::number(i);
// btn->setText(Sbtn);
// layout->addWidget(btn);
// }
}
SessionFriendItem::SessionFriendItem(QWidget *owner, const QIcon *avatar, const QString *name, const QString &text)
{
}