qt实现QQ登录页面
代码
mywidget.h
cpp
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
#include <QMovie>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = nullptr);
~MyWidget();
};
#endif // MYWIDGET_H
main.cpp
cpp
#include "mywidget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();
return a.exec();
}
mywidget.cpp
cpp
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
//重新设置窗口大小
this->resize(860,660);
//设置动态窗口图标标签
QLabel *lab=new QLabel(this);
lab->resize(860,260);
QMovie *movie=new QMovie("C:\\Users\\21925\\Desktop\\pictrue\\3.gif");
lab->setMovie(movie);
lab->setScaledContents(true);
movie->start();
//设置纯净窗口
this->setWindowFlag(Qt::FramelessWindowHint);
//设置QQ标签
QLabel *lab1=new QLabel(this);
lab1->resize(40,40);
lab1->move(70,20);
lab1->setText("QQ");
//QQ logo标签
QLabel *lab2=new QLabel(this);
lab2->resize(40,40); //重新设置尺寸
lab2->move(20,20);
lab2->setPixmap(QPixmap("C:\\Users\\21925\\Desktop\\pictrue\\qq.png"));
lab2->setScaledContents(true); //图片自适应
//账户图标标签
QLabel *lab3=new QLabel(this);
lab3->resize(75,70);
lab3->move(185,325);
lab3->setPixmap(QPixmap("C:\\Users\\21925\\Desktop\\pictrue\\qq.png"));
lab3->setScaledContents(true);
//密码图标标签
QLabel *lab4=new QLabel(this);
lab4->resize(75,70);
lab4->move(185,400);
lab4->setPixmap(QPixmap("C:\\Users\\21925\\Desktop\\pictrue\\passwd.jpg"));
lab4->setScaledContents(true);
//账号
QLineEdit *ed1=new QLineEdit(this);
ed1->resize(390,70);
ed1->move(270,325);
ed1->setPlaceholderText("QQ号码/手机/邮箱");
//密码
QLineEdit *ed2=new QLineEdit(this);
ed2->resize(390,70);
ed2->move(270,400);
ed2->setPlaceholderText("密码");
// //改变字体大小
// QFont ft;
// ft.setPointSize(7);
//自动登录标签
QLabel *lab5=new QLabel(this);
lab5->resize(130,30);
lab5->move(195,490);
lab5->setText("自动登录");
//lab5->setFont(ft);
lab5->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); //文字自适应
lab5->adjustSize();
//记住密码标签
QLabel *lab6=new QLabel(this);
lab6->resize(130,30);
lab6->move(380,490);
lab6->setText("记住密码");
//lab6->setFont(ft);
lab6->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
lab6->adjustSize();
//找回密码标签
QLabel *lab7=new QLabel(this);
lab7->resize(80,30);
lab7->move(565,490);
lab7->setText("记住密码");
//lab7->setFont(ft);
lab7->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
lab7->adjustSize();
//登录按钮
QPushButton *btn=new QPushButton(this);
btn->resize(480,75);
btn->move(185,545);
btn->setText("登录");
btn->setStyleSheet("background:rgb(4,186,251)");
//注册账号按钮
QPushButton *btn1=new QPushButton(this);
btn1->resize(130,30);
btn1->move(20,600);
btn1->setText("注册账号");
btn1->setStyleSheet("background-color:white");
btn1->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
btn1->adjustSize();
//二维码按钮
QPushButton *btn2=new QPushButton(this);
btn2->resize(60,60);
btn2->move(780,580);
btn2->setIcon(QIcon("C:\\Users\\21925\\Desktop\\pictrue\\1.png"));
btn2->setStyleSheet("background-color:white");
}
MyWidget::~MyWidget()
{
}