update layout code

This commit is contained in:
xyz
2025-05-21 20:03:37 +08:00
parent bc81e30058
commit f529ecb251
2 changed files with 20 additions and 3 deletions

View File

@ -15,6 +15,14 @@ class SessionFriendArea : public QScrollArea
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;
@ -32,13 +40,13 @@ class SessionFriendItem : public QWidget {
Q_OBJECT
public:
SessionFriendItem(QWidget* owner, const QIcon* avatar, const QString* name, const QString& text);
SessionFriendItem(QWidget* owner, const QIcon& avatar, const QString& name, const QString& text);
private:
//owner 就是指向了 SessionFriendArea
QWidget* owner;
//表示当前的Item是否是选中的状态
//表示当前的Item是否是选中的状态(选中时其背景色会有所不同)
bool selected = false;
};