Files
MyChat_Client/sessionfriendarea.h
2025-05-21 20:03:37 +08:00

55 lines
1.2 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.

#ifndef SESSIONFRIENDAREA_H
#define SESSIONFRIENDAREA_H
#include <QWidget>
#include <QScrollArea>
////////////////////////////////////////
/// 整个滚动区域的实现
////////////////////////////////////////
class SessionFriendArea : public QScrollArea
{
Q_OBJECT
public:
explicit SessionFriendArea(QWidget *parent = nullptr);
//清空区域内所有的Item
void clear();
//添加一个Item
void addItem(const QIcon& avatar, const QString& name, const QString& text);
//
private:
//后续向container中的layout添加元素就会有QScrollArea的滚动
QWidget* container;
signals:
};
////////////////////////////////////////
/// 滚动区域的Item的实现
////////////////////////////////////////
class SessionFriendItem : public QWidget {
//可以使当前的类使用信号与槽相关的操作
Q_OBJECT
public:
SessionFriendItem(QWidget* owner, const QIcon& avatar, const QString& name, const QString& text);
private:
//owner 就是指向了 SessionFriendArea
QWidget* owner;
//表示当前的Item是否是选中的状态(选中时其背景色会有所不同)
bool selected = false;
};
#endif // SESSIONFRIENDAREA_H