From f529ecb251c9ae2377666a95c03feed16e9ce325 Mon Sep 17 00:00:00 2001 From: xyz <2050965275@qq.com> Date: Wed, 21 May 2025 20:03:37 +0800 Subject: [PATCH] update layout code --- sessionfriendarea.cpp | 11 ++++++++++- sessionfriendarea.h | 12 ++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sessionfriendarea.cpp b/sessionfriendarea.cpp index c97fd5e..0db23ce 100644 --- a/sessionfriendarea.cpp +++ b/sessionfriendarea.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include SessionFriendArea::SessionFriendArea(QWidget *parent) : QScrollArea {parent} @@ -34,7 +36,14 @@ SessionFriendArea::SessionFriendArea(QWidget *parent) // } } -SessionFriendItem::SessionFriendItem(QWidget *owner, const QIcon *avatar, const QString *name, const QString &text) +void SessionFriendArea::clear() { } + +void SessionFriendArea::addItem(const QIcon &avatar, const QString &name, const QString &text) +{ + +} + + diff --git a/sessionfriendarea.h b/sessionfriendarea.h index d21d613..f2d3174 100644 --- a/sessionfriendarea.h +++ b/sessionfriendarea.h @@ -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; };