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

@ -2,6 +2,8 @@
#include <QScrollBar> #include <QScrollBar>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QGridLayout>
#include <QLabel>
SessionFriendArea::SessionFriendArea(QWidget *parent) SessionFriendArea::SessionFriendArea(QWidget *parent)
: QScrollArea {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)
{
}

View File

@ -15,6 +15,14 @@ class SessionFriendArea : public QScrollArea
public: public:
explicit SessionFriendArea(QWidget *parent = nullptr); explicit SessionFriendArea(QWidget *parent = nullptr);
//清空区域内所有的Item
void clear();
//添加一个Item
void addItem(const QIcon& avatar, const QString& name, const QString& text);
//
private: private:
//后续向container中的layout添加元素就会有QScrollArea的滚动 //后续向container中的layout添加元素就会有QScrollArea的滚动
QWidget* container; QWidget* container;
@ -32,13 +40,13 @@ class SessionFriendItem : public QWidget {
Q_OBJECT Q_OBJECT
public: 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: private:
//owner 就是指向了 SessionFriendArea //owner 就是指向了 SessionFriendArea
QWidget* owner; QWidget* owner;
//表示当前的Item是否是选中的状态 //表示当前的Item是否是选中的状态(选中时其背景色会有所不同)
bool selected = false; bool selected = false;
}; };