1.手动实现登录框
要求:
1、登录窗口更改标题、图标
2、设置固定尺寸、并给定一定的透明度
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
//设置 固定尺寸
this->setFixedSize(1000,700);
//设置图标
this->setWindowIcon(QIcon("C:\\Users\\user\\Desktop\\C++\\img\\微信.png"));
//设置标题
this->setWindowTitle("鹏哥快聊");
//设置透明度
this->setWindowOpacity(0.8);
//添加图片标签
lb1=new QLabel(this);
lb1->move(0,0);
lb1->resize(1000,300);
lb1->setStyleSheet("border_radius:20;");
lb1->setPixmap(QPixmap("C:\\Users\\user\\Desktop\\C++\\img\\chat.png"));
lb1->setScaledContents(true);
//添加文字标签
lb2=new QLabel(this);
lb2->move(220,320);
lb2->resize(85,75);
lb2->setPixmap(QPixmap("C:\\Users\\user\\Desktop\\C++\\img\\账户.png"));
lb2->setScaledContents(true);
lb2->setAlignment(Qt::AlignCenter);
lb3=new QLabel(this);
lb3->move(200,405);
lb3->resize(125,75);
lb3->setPixmap(QPixmap("C:\\Users\\user\\Desktop\\C++\\img\\密码.png"));
lb3->setScaledContents(true);
lb3->setAlignment(Qt::AlignCenter);
//添加行文本
line1=new QLineEdit(this);
line1->move(310,320);
line1->resize(470,75);
line1->setPlaceholderText("请输入账号");
line1->setStyleSheet("border:none;"
"font-size:30px;");
line2=new QLineEdit(this);
line2->move(310,405);
line2->resize(470,75);
line2->setPlaceholderText("请输入密码");
line2->setStyleSheet("border:none;"
"font-size:30px;");
line2->setEchoMode(QLineEdit::Password);
//添加按钮
btn1=new QPushButton(this);
btn1->move(400,500);
btn1->resize(100,60);
btn1->setIcon(QIcon("C:\\Users\\user\\Desktop\\C++\\img\\登录.png"));
btn1->setIconSize(QSize(100,60));
btn2=new QPushButton(this);
btn2->move(520,500);
btn2->resize(100,60);
btn2->setIcon(QIcon("C:\\Users\\user\\Desktop\\C++\\img\\取消.png"));
btn2->setIconSize(QSize(100,50));
}
Widget::~Widget()
{
}
2.脑图