Qtday01(qt简介、简单窗口组件)

今日任务

仿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()
{
}

实现效果:

今日思维导图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值