cpp
复制代码
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
//窗口设置
this->setWindowTitle("登录窗口");
this->setWindowIcon(QIcon("C:\\Users\\汪君伟\\Desktop\\pictrue\\qq.png"));
this->resize(530,412);
this->setWindowFlag(Qt::FramelessWindowHint);
this->setStyleSheet("background-color:white");
//标签设置
QLabel *lab1 = new QLabel(this);
lab1->resize(330,155);
lab1->move(110,0);
//lab1->setStyleSheet("background-color:white");
//加载动图
QMovie *mv = new QMovie("C:\\Users\\汪君伟\\Desktop\\pictrue\\123.gif");
lab1->setMovie(mv);
mv->start();
lab1->setScaledContents(true);
//加载图片
QLabel *lab2 = new QLabel(this);
lab2->resize(40,50);
lab2->setPixmap(QPixmap("C:\\Users\\汪君伟\\Desktop\\pictrue\\qq.png"));
lab2->setScaledContents(true);
QLabel *lab3 = new QLabel(this);
lab3->resize(25,25);
lab3->move(150,250);
lab3->setPixmap(QPixmap("C:\\Users\\汪君伟\\Desktop\\pictrue\\wodepeizhenshi.png"));
lab3->setScaledContents(true);
QLabel *lab4 = new QLabel(this);
lab4->resize(25,25);
lab4->move(150,290);
lab4->setPixmap(QPixmap("C:\\Users\\汪君伟\\Desktop\\pictrue\\passwd.jpg"));
lab4->setScaledContents(true);
QLabel *lab5 = new QLabel("QQ",this);
lab5->resize(40,50);
lab5->move(40,0);
QLabel *lab6 = new QLabel(this);
lab6->resize(80,80);
lab6->move(225,130);
lab6->setPixmap(QPixmap("C:\\Users\\汪君伟\\Desktop\\pictrue\\1.webp"));
lab6->setScaledContents(true);
//创建第一个行编辑器
QLineEdit *ed1 = new QLineEdit;
ed1->setParent(this);
ed1->move(180,250);
ed1->setPlaceholderText("账号");
//创建第二个行编辑器
QLineEdit *ed2 = new QLineEdit(this);
ed2->setEchoMode(QLineEdit::Password);
ed2->move(180,290);
ed2->setPlaceholderText("密码");
//创建第一个按钮,使用无参构造
QPushButton *btn1 = new QPushButton;
//设置按钮文本
btn1->setText("登录");
//设置按钮位置
btn1->move(125,330);
//设置按钮大小
btn1->resize(300,45);
//指定父对象,可以依赖父对象显示,可以不用管它的释放操作
btn1->setParent(this);
//设置按钮颜色
btn1->setStyleSheet("background-color:rgb(5,160,255);border-radius:3");
}
MyWidget::~MyWidget()
{
}