mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 00:51:48 +08:00
update SelfInfoWidget
This commit is contained in:
176
SelfInfoWidget.cpp
Normal file
176
SelfInfoWidget.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
#include "SelfInfoWidget.h"
|
||||
|
||||
SelfInfoWidget::SelfInfoWidget(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
//设置整个窗口的属性
|
||||
this->setFixedSize(450, 250);
|
||||
this->setWindowTitle("个人信息");
|
||||
this->setWindowIcon(QIcon(":/resource/image/logo.png"));
|
||||
//窗口被关闭时,自动销毁这个对话框对象
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
//把窗口移动到鼠标当前的位置
|
||||
this->move(QCursor::pos());
|
||||
|
||||
//创建布局管理器
|
||||
QGridLayout* layout = new QGridLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
this->setLayout(layout);
|
||||
|
||||
//创建头像
|
||||
avatarBtn = new QPushButton();
|
||||
avatarBtn->setFixedSize(75, 75);
|
||||
avatarBtn->setIconSize(QSize(75, 75));
|
||||
avatarBtn->setIcon(QIcon(":/resource/image/defaultAvatar.png"));
|
||||
avatarBtn->setStyleSheet("QPushButton { border: none; background-color: transparent; }");
|
||||
|
||||
QString labelStyle = "QLabel { font-size: 14px; font-weight: 800; }";
|
||||
QString btnStyle = "QPushButton {border: none; background-color: transparent; }";
|
||||
btnStyle += "QPushButton:pressed { background-color: rgb(210, 210, 210); }";
|
||||
|
||||
int height = 30;
|
||||
|
||||
//添加用户的ID的显示
|
||||
idTag = new QLabel();
|
||||
idTag->setFixedSize(50, height);
|
||||
idTag->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
idTag->setText("序号");
|
||||
idTag->setStyleSheet(labelStyle);
|
||||
|
||||
idLabel = new QLabel();
|
||||
idLabel->setFixedHeight(height);
|
||||
idLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
//添加新的用户的名字的显示
|
||||
nameTag = new QLabel();
|
||||
nameTag->setFixedSize(50, height);
|
||||
nameTag->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
nameTag->setText("昵称");
|
||||
nameTag->setStyleSheet(labelStyle);
|
||||
|
||||
nameLabel = new QLabel();
|
||||
nameLabel->setFixedHeight(height);
|
||||
nameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
nameModifyBtn = new QPushButton();
|
||||
nameModifyBtn->setFixedSize(25, 25);
|
||||
nameModifyBtn->setIconSize(QSize(20, 20));
|
||||
nameModifyBtn->setIcon(QIcon(":/resource/image/modify.png"));
|
||||
nameModifyBtn->setStyleSheet(btnStyle);
|
||||
|
||||
nameEdit = new QLineEdit();
|
||||
nameEdit->setFixedHeight(height);
|
||||
nameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
nameEdit->hide();
|
||||
|
||||
nameSubmitBtn = new QPushButton();
|
||||
nameSubmitBtn->setFixedSize(25, 25);
|
||||
nameSubmitBtn->setIconSize(QSize(20, 20));
|
||||
nameSubmitBtn->setIcon(QIcon(":/resource/image/submit.png"));
|
||||
nameSubmitBtn->setStyleSheet(btnStyle);
|
||||
nameSubmitBtn->hide();
|
||||
|
||||
//添加个性签名
|
||||
descTag = new QLabel();
|
||||
descTag->setFixedSize(50, height);
|
||||
descTag->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
descTag->setText("签名");
|
||||
descTag->setStyleSheet(labelStyle);
|
||||
|
||||
descLabel = new QLabel();
|
||||
descLabel->setFixedHeight(height);
|
||||
descLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
descModifyBtn = new QPushButton();
|
||||
descModifyBtn->setFixedSize(25, 25);
|
||||
descModifyBtn->setIconSize(QSize(20, 20));
|
||||
descModifyBtn->setIcon(QIcon(":/resource/image/modify.png"));
|
||||
descModifyBtn->setStyleSheet(btnStyle);
|
||||
|
||||
descEdit = new QLineEdit();
|
||||
descEdit->setFixedHeight(height);
|
||||
descEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
descEdit->hide();
|
||||
|
||||
descSubmitBtn = new QPushButton();
|
||||
descSubmitBtn->setFixedSize(25, 25);
|
||||
descSubmitBtn->setIconSize(QSize(20, 20));
|
||||
descSubmitBtn->setIcon(QIcon(":/resource/image/modify.png"));
|
||||
descSubmitBtn->setStyleSheet(btnStyle);
|
||||
descSubmitBtn->hide();
|
||||
|
||||
// 7. 添加电话
|
||||
phoneTag = new QLabel();
|
||||
phoneTag->setFixedSize(50, height);
|
||||
phoneTag->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
phoneTag->setText("电话");
|
||||
phoneTag->setStyleSheet(labelStyle);
|
||||
|
||||
phoneLabel = new QLabel();
|
||||
phoneLabel->setFixedHeight(height);
|
||||
phoneLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
phoneModifyBtn = new QPushButton();
|
||||
phoneModifyBtn->setFixedSize(25, 25);
|
||||
phoneModifyBtn->setIconSize(QSize(20, 20));
|
||||
phoneModifyBtn->setIcon(QIcon(":/resource/image/modify.png"));
|
||||
phoneModifyBtn->setStyleSheet(btnStyle);
|
||||
|
||||
phoneEdit = new QLineEdit();
|
||||
phoneEdit->setFixedHeight(height);
|
||||
phoneEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
phoneEdit->hide();
|
||||
|
||||
phoneSubmitBtn = new QPushButton();
|
||||
phoneSubmitBtn->setFixedSize(25, 25);
|
||||
phoneSubmitBtn->setIconSize(QSize(20, 20));
|
||||
phoneSubmitBtn->setIcon(QIcon(":/resource/image/submit.png"));
|
||||
phoneSubmitBtn->setStyleSheet(btnStyle);
|
||||
phoneSubmitBtn->hide();
|
||||
|
||||
|
||||
// 8. 添加验证码
|
||||
verifyCodeTag = new QLabel();
|
||||
verifyCodeTag->setFixedSize(50, height);
|
||||
verifyCodeTag->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
verifyCodeTag->setText("输入验证码:");
|
||||
verifyCodeTag->setStyleSheet(labelStyle);
|
||||
|
||||
verifyCodeEdit = new QLineEdit();
|
||||
verifyCodeEdit->setFixedHeight(height);
|
||||
verifyCodeEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
//verifyCodeEdit->hide();
|
||||
|
||||
getVerifyCodeBtn = new QPushButton();
|
||||
getVerifyCodeBtn->setText("获取验证码");
|
||||
|
||||
|
||||
layout->addWidget(avatarBtn, 0, 0, 3, 1);
|
||||
layout->addWidget(idTag, 0, 1);
|
||||
layout->addWidget(idLabel, 0, 2);
|
||||
|
||||
layout->addWidget(nameTag, 1, 1);
|
||||
layout->addWidget(nameLabel, 1, 2);
|
||||
layout->addWidget(nameModifyBtn, 1, 3);
|
||||
|
||||
layout->addWidget(descTag, 2, 1);
|
||||
layout->addWidget(descLabel, 2, 2);
|
||||
layout->addWidget(descModifyBtn, 2, 3);
|
||||
|
||||
layout->addWidget(phoneTag, 3, 1);
|
||||
layout->addWidget(phoneLabel, 3, 2);
|
||||
layout->addWidget(phoneModifyBtn, 3, 3);
|
||||
|
||||
layout->addWidget(verifyCodeTag, 4, 1);
|
||||
layout->addWidget(verifyCodeEdit, 4, 2);
|
||||
layout->addWidget(getVerifyCodeBtn, 4, 3);
|
||||
|
||||
#if TEST_UI
|
||||
idLabel->setText("12345");
|
||||
nameLabel->setText("xyz");
|
||||
descLabel->setText("It didn't matter that i lived another day.");
|
||||
phoneLabel->setText("12345678900");
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user