作为一个真真正正的ikun,哥哥就是我前进下去的最大动力,最近浅浅学了一手QT,就用QT来做一个登陆界面,登录ikun账号。
#ifndef HOMEWORK_H
#define HOMEWORK_H
#include <QWidget>
#include <QIcon>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QMovie>
class homework : public QWidget
{
Q_OBJECT
public:
homework(QWidget *parent = nullptr);
~homework();
};
#endif // HOMEWORK_H
#include "homework.h"
homework::homework(QWidget *parent)
: QWidget(parent)
{
//设置窗口属性
this->setWindowTitle("IKUN");
this->setWindowIcon(QIcon("D:/con.png"));
this->setFixedSize(560,450);
//this->setStyleSheet("background-color:white");
this->setWindowFlag(Qt::FramelessWindowHint);
//设置标签属性,gif属性
QLabel *lab = new QLabel(this);
lab->resize(560,180);
QMovie *mv = new QMovie("D:/gege2.gif");
lab->setMovie(mv);
mv->start();
lab->setScaledContents(true);
//添加左上角标签
QLabel *l_lab = new QLabel(this);
l_lab->resize(40,40);
l_lab->move(20,20);
l_lab->setPixmap(QPixmap("D:/icon_pure"));
//l_lab->setStyleSheet("border-radius:15px");
l_lab->setScaledContents(true);
QLabel *areaLabel = new QLabel(this);
areaLabel->setGeometry(0, 180, 560, 270);
areaLabel->setStyleSheet("background-color:white");
//添加-和×
QLabel *min = new QLabel("-",this);
min->resize(30,30);
min->move(510,0);
QLabel *clo = new QLabel("×",this);
clo->resize(30,30);
clo->move(540,0);
//添加头像标签
QLabel *h_lab = new QLabel(this);
h_lab->resize(100,100);
h_lab->move(230,130);
h_lab->setPixmap(QPixmap("D:/ikun_pure.png"));
//h_lab->setStyleSheet("border-radius:50px");
h_lab->setScaledContents(true);
//添加账户标签
QLabel *acc_lab = new QLabel(this);
acc_lab->resize(30,30);
acc_lab->move(140,250);
acc_lab->setPixmap(QPixmap("D:/ball2.png"));
acc_lab->setScaledContents(true);
//添加账户行编辑器
QLineEdit *acc = new QLineEdit(this);
acc->resize(280,30);
acc->move(170,250);
acc->setPlaceholderText("ikun-id");
//添加密码标签
QLabel *pw_lab = new QLabel(this);
pw_lab->resize(30,30);
pw_lab->move(140,290);
pw_lab->setPixmap(QPixmap("D:/chicken.png"));
pw_lab->setScaledContents(true);
//添加密码行编辑器
QLineEdit *pw = new QLineEdit(this);
pw->resize(280,30);
pw->move(170,290);
pw->setPlaceholderText("password");
pw->setEchoMode(QLineEdit::Password);
//添加下方三个标签
QLabel *sing = new QLabel("自动登录",this);
sing->resize(100,30);
sing->move(170,320);
QLabel *dance = new QLabel("坤住密码",this);
dance->resize(100,30);
dance->move(270,320);
QLabel *rap = new QLabel("找回密码",this);
rap->resize(100,30);
rap->move(370,320);
//添加登录按钮
QPushButton *login = new QPushButton("登录",this);
login->resize(300,45);
login->move(148,350);
login->setStyleSheet("background-color:skyblue;border-radius:5px");
//添加左下角标签
QLabel *signup = new QLabel("注册ikun账号",this);
signup->resize(100,30);
signup->move(0,415);
//添加右下角gif
QLabel *r_lab = new QLabel(this);
r_lab->resize(50,50);
QMovie *r_mv = new QMovie("D:/kg.gif");
r_lab->setMovie(r_mv);
r_mv->start();
r_lab->move(510,400);
r_lab->setScaledContents(true);
}
homework::~homework()
{
}
运行效果: