#include "homework.h"
homework::homework(QWidget *parent)
: QWidget(parent)
{
this->resize(540, 620);//设置窗口大小
this->setFixedSize(540, 620);//设置固定窗口大小
this->setWindowFlag(Qt::FramelessWindowHint);//设置纯净窗口
this->setStyleSheet("background-color:white");//设置窗口背景为白色
//*******************标签设置******************************************************\n
QLabel *lab1 = new QLabel(this);//设置顶部动图标签
lab1->resize(540, 304);//设置动图标签大小
//lab1->setStyleSheet("background-color:black");
QMovie *mv = new QMovie("C:\\hqyj\\qt\\pictrue\\pictrue\\2.gif");//创建动图指针
lab1->setMovie(mv);//导入动图
mv->start();//开始动态显示图
lab1->setScaledContents(true);//自适应动图大小
//\n
QLabel *lab2 = new QLabel(this);//设置左上角图标标签
lab2->resize(64, 40);//设置左上角图标大小
lab2->move(30, 30);//移动至左上角位置
lab2->setPixmap(QPixmap("C:\\hqyj\\qt\\pictrue\\pictrue\\3.jpeg"));//填充图片
lab2->setScaledContents(true);//自适应大小
//\n
QLabel *lab3 = new QLabel(this);//设置登录界面id标签
lab3->resize(20, 20);//设置标签图片大小
lab3->move(130, 400);//移动至指定位置
lab3->setPixmap(QPixmap("C:\\hqyj\\qt\\pictrue\\pictrue\\4.jpeg"));//填充图片
lab3->setScaledContents(true);//自适应大小
//\n
QLabel *lab4 = new QLabel(this);//设置登录界面密码标签
lab4->resize(20, 20);//设置标签大小
lab4->move(130, 430);//移动之指定位置
lab4->setPixmap(QPixmap("C:\\hqyj\\qt\\pictrue\\pictrue\\passwd.jpg"));//填充图片
lab4->setScaledContents(true);//自适应大小
//\n
QLabel *lab5 = new QLabel(this);
lab5->resize(80, 80);
lab5->move(230, 264);
lab5->setStyleSheet("border-radius: 40px");
lab5->setPixmap(QPixmap("C:\\hqyj\\qt\\pictrue\\pictrue\\6.jpeg"));
lab5->setScaledContents(true);
//*******************文本编辑器设置******************************************************\n
QLineEdit *edit1 = new QLineEdit(this);//设置id文本编辑器
edit1->resize(280, 20);//设置文本框大小
edit1->move(150, 400);//移动至指定位置
edit1->setPlaceholderText("id: ");//占位提示输入id
//\n
QLineEdit *edit2 = new QLineEdit(this);//设置密码编辑器文本
edit2->resize(280, 20);//设置文本框大小
edit2->move(150, 430);//移动至指定位置
edit2->setPlaceholderText("password: ");//占位提示输入密码
//*******************按钮设置*******************************\n
QPushButton *push1 = new QPushButton(this);//设置登录按钮
push1->resize(300, 45);//设置登录按钮大小
push1->move(130, 460);//移动到指定位置
push1->setText("登录");//设置按钮文本为“登录”
push1->setStyleSheet("background-color:blue; border-radius:8px");//设置按钮颜色为蓝色,圆角
//\n
QPushButton *push2 = new QPushButton(this);
push2->resize(30, 30);
push2->move(510, 0);
push2->setText("×");
push2->setStyleSheet("background-color:transparent");
//\n
QPushButton *push3 = new QPushButton(this);
push3->resize(30, 30);
push3->move(480, 0);
push3->setText("-");
push3->setStyleSheet("background-color:transparent");
}
c++实现登录界面
最新推荐文章于 2024-05-14 02:25:58 发布