mywidget.cpp
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
//窗口设置
this->resize(645,490); //重设窗口大小
this->setWindowTitle("QQ"); //重设窗口名字
this->setWindowIcon(QIcon("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\qq.png")); //设置窗口图标
this->setWindowFlag(Qt::FramelessWindowHint); //设置纯净窗口
this->setStyleSheet("background-color:white;border:1px"); //设置窗口背景颜色
//设置label
QLabel *lab1 = new QLabel(this);
lab1->resize(645,190);
QMovie *mv = new QMovie("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\picture1.gif"); //动态图
mv->start();
lab1->setMovie(mv);
lab1->setScaledContents(true); //自适应
//小图标
QLabel *lab2 = new QLabel(this);
lab2->setStyleSheet("background-color:transparent"); //设置label背景为透明
lab2->resize(30,30);
lab2->move(20,20);
lab2->setPixmap(QPixmap("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\title.png"));
lab2->setScaledContents(true);
//QQ文字
QLabel *lab3 = new QLabel(this);
lab3->move(60,25);
lab3->setText("QQ");
lab3->setStyleSheet("background-color:transparent;color:white;font:20px"); //背景透明
//用户登录文字框
QLabel *lab4 = new QLabel(this);
lab4->move(150,260);
lab4->resize(30,30);
lab4->setStyleSheet("background:transparent"); //透明背景
lab4->setPixmap(QPixmap("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\login.png"));
lab4->setScaledContents(true);
QLineEdit *ed1 = new QLineEdit(this);
ed1->move(185,260);
ed1->resize(360,40);
//ed1->setStyleSheet("border-color:rgb(128,128,128)");
ed1->setPlaceholderText("QQ号码/手机/邮箱"); //设置占位
QLabel *lab5 = new QLabel(this);
lab5->move(150,300);
lab5->resize(30,30);
lab5->setStyleSheet("background-color:transparent");
lab5->setPixmap(QPixmap("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\passwd.png"));
lab5->setScaledContents(true);
QLineEdit *ed2 = new QLineEdit(this);
ed2->move(185,300);
ed2->resize(360,40);
ed2->setStyleSheet("border-color:rgb(128,128,128)");
ed2->setPlaceholderText("密码"); //设置占位
ed2->setEchoMode(QLineEdit::Password);
//单选框1
QCheckBox *box1 = new QCheckBox(this);
box1->move(145,370);
box1->resize(20,20);
//box1->setStyleSheet("border-color:rgb(128,128,128)");
QLabel *lab6 = new QLabel(this);
lab6->move(170,370);
lab6->resize(75,20);
lab6->setText("自动登录");
lab6->setStyleSheet("color:rgb(128,128,128)");
//单选框2
QCheckBox *box2 = new QCheckBox(this);
box2->move(285,370);
box2->resize(20,20);
//box2->setStyleSheet("border-color:rgb(128,128,128)");
QLabel *lab7 = new QLabel(this);
lab7->move(310,370);
lab7->resize(75,20);
lab7->setText("记住密码");
lab7->setStyleSheet("color:rgb(128,128,128)");
QPushButton *btn = new QPushButton(this);
btn->resize(75,20);
btn->move(425,370);
btn->setText("找回密码");
btn->setStyleSheet("background-color:transparent;color:rgb(128,128,128)");
btn->setEnabled(true);
QPushButton *btn1 = new QPushButton(this);
btn1->resize(75,20);
btn1->move(20,460);
btn1->setText("注册账号");
btn1->setStyleSheet("background-color:transparent;color:rgb(128,128,128)");
btn1->setEnabled(true);
//登录按钮
QPushButton *btn2 = new QPushButton(this);
btn2->resize(360,55);
btn2->move(145,410);
btn2->setText("登录");
btn2->setStyleSheet("background-color:rgb(7,188,252);border-radius:10px;color:white;font:20px");
btn2->setEnabled(true);
//头像
QLabel *lab8 = new QLabel(this);
lab8->move(260,135);
lab8->resize(130,130);
lab8->setStyleSheet("background-color:transparent");
lab8->setPixmap(QPixmap("D:\\Users\\noora\\Desktop\\q\\QT\\ICON\\qq.png"));
lab8->setScaledContents(true); //自适应
}
MyWidget::~MyWidget()
{
}
mywidget.h
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
#include <QIcon>
#include <QLabel>
#include <QMovie>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = nullptr);
~MyWidget();
};
#endif // MYWIDGET_H