mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 00:51:48 +08:00
Write the layout
This commit is contained in:
40
sessionfriendarea.cpp
Normal file
40
sessionfriendarea.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#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)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user