今日任务
仿qq登录界面,QT实现
代码:
头文件:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QtDebug>
#include <QIcon>
#include <QMovie>
#include <QRadioButton>
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
};
#endif // MAINWINDOW_H
功能函数,窗口类:
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->resize(530,410);
    this->setWindowTitle("知音");
    this->setWindowIcon(QIcon("C:\\Users\\hasee\\Desktop\\111\\logo.jpg"));
    //this->setWindowFlag(Qt::FramelessWindowHint);//无边框
    this->setStyleSheet("background-color:#faf7ec");
    QLabel *label2=new QLabel(this);
    label2->resize(530,180);
    QMovie *movie = new QMovie("C:\\Users\\hasee\\Desktop\\111\\cai.gif");
    label2->setMovie(movie);
    label2->setScaledContents(true);
    movie->start();
    QLabel *label1=new QLabel(this);
    label1->resize(50,50);
    label1->setPixmap(QPixmap("C:\\Users\\hasee\\Desktop\\111\\篮球.png"));
    label1->setScaledContents(true);
    QLabel *accout=new QLabel(this);
    accout->resize(30,30);
    accout->setPixmap(QPixmap("C:\\Users\\hasee\\Desktop\\111\\account.jpg"));
    accout->setScaledContents(true);
    accout->move(150,210);
    QLabel *passwd=new QLabel(this);
    passwd->resize(30,30);
    passwd->setPixmap(QPixmap("C:\\Users\\hasee\\Desktop\\111\\passwd.jpg"));
    passwd->setScaledContents(true);
    passwd->move(150,250);
    QLabel *user=new QLabel(this);
    user->resize(65,65);
    user->move(230,142);
    //user->setPixmap(QPixmap("C:\\Users\\hasee\\Desktop\\111\\logo.jpg"));
    user->setStyleSheet("border-image:url(C:/Users/hasee/Desktop/111/user.png);border-radius:30px");
    user->setScaledContents(true);
    QLineEdit *l1=new QLineEdit(this);
    l1->setPlaceholderText("账号");
    l1->resize(200,30);
    l1->move(190,210);
    QLineEdit *l2=new QLineEdit(this);
    l2->setPlaceholderText("密码");
    l2->resize(200,30);
    l2->move(190,250);
    QRadioButton *radio1=new QRadioButton("自动登录",this);
    radio1->resize(85,30);
    radio1->move(150,290);
    QRadioButton *radio2=new QRadioButton("记住密码",this);
    radio2->resize(85,30);
    radio2->move(240,290);
    QLabel *radio3=new QLabel("找回密码",this);
    radio3->resize(85,30);
    radio3->move(340,290);
    QPushButton *login=new QPushButton("登录",this);
    login->resize(250,40);
    login->move(150,330);
    login->setStyleSheet("background-color:#409EFF;border-radius:5px");
    QLabel *regist=new QLabel("<a href=#>注册账号</a>",this);
    regist->move(15,380);
    regist->resize(100,20);
    QLabel *login2=new QLabel(this);
    login2->setPixmap(QPixmap("C:\\Users\\hasee\\Desktop\\111\\2.png"));
    login2->move(480,360);
    login2->resize(40,40);
}
MainWindow::~MainWindow()
{
}
实现效果:

今日思维导图:




















