2>自由发挥登录窗口的应用场景,实现一个登录窗口界面
要求:每行代码都有注释
【需要用到的图片或者动图,自己去网上找】
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
//********************窗口栏******************
this->setWindowFlag(Qt::FramelessWindowHint); //将窗口栏设为无;
this->resize(1080,600); //设置窗口的大小
this->setStyleSheet("background-color:rgb(0,0,0)");//设置窗口底色
//*****************设置标签*******************
QLabel *lab1 = new QLabel(this); //申请空间
lab1->resize(40,30); //设置标签大小
//lab1->setStyleSheet("background-color:white");//设置颜色
lab1->move(370,0);//移动标签位置
lab1->setPixmap(QPixmap("C:\\Users\\Administrator\\Desktop\\pictrue\\passwd.jpg"));
lab1->setScaledContents(true); //自动适应
QLabel *lab2 = new QLabel(this);
lab2->resize(50,50);
lab2->move(470,200);
lab2->setStyleSheet("color:white");
lab2->setText("WeGame");
QLabel *lab3 = new QLabel(this);
lab3->move(450,450);
lab3->resize(80,20);
lab3->setText("保存密码");
lab3->setStyleSheet("color:white");
QLabel *lab4 = new QLabel(this);
lab4->move(550,450);
lab4->resize(80,20);
lab4->setText("自动登录");
lab4->setStyleSheet("color:white");
//*************** 设置行编辑器 **********************
QLineEdit *edit1 =new QLineEdit(this);
edit1 ->resize(250,50);
edit1 ->move(400,300);
edit1 ->setStyleSheet("background-color:rgb(0.0)");
edit1 ->setPlaceholderText("QQ账号/手机号");
QLineEdit *edit2 =new QLineEdit(this);
edit2 ->resize(250,50);
edit2 ->move(400,370);
edit2 ->setStyleSheet("background-color:rgb(0.0)");
edit2 ->setPlaceholderText("密码");
edit2 ->setEchoMode(QLineEdit::Password);
//****************设置按钮 *********************
QPushButton *but1 = new QPushButton("登录",this);
but1 ->resize(250,50);
but1 ->move(400,470);
but1->setStyleSheet("background-color:orange;color:black");
QPushButton *but2 = new QPushButton("快速安全登录",this);
but2 ->resize(100,20);
but2 ->move(470,540);
but2->setStyleSheet("background-color:black;color:white");
}
MyWidget::~MyWidget()
{
}