• day1_QT


    实现登录窗口

    #include "loginwindow.h"
    
    LoginWindow::LoginWindow(QWidget *parent)
        : QWidget(parent)
    {
        //设置窗口标题和图标
        this->setWindowTitle("ChatWe");
        this->setWindowIcon(QIcon("D:\\learn\\QT\\day1\\work\\login.png"));
    
        //设置窗口的大小 固定
        this->setFixedSize(800,500);
    
        //设置上1/2处label图标放置背景图
        QLabel *labelpic = new QLabel(this);
        //一半大小
        labelpic->resize(800,250);
        //放入图片
        labelpic->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\bg.png"));
    
        /***********************************************************************/
    
        //账号图标
        QLabel *labelaccount = new QLabel(this);
        labelaccount->resize(50,50);
        //移动位置
        labelaccount->move(150,280);
        labelaccount->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\account.png"));
        labelaccount->setScaledContents(true);
    
        //账号编辑框
        QLineEdit *editaccount = new QLineEdit(this);
        editaccount->setPlaceholderText("请输入账号");
        editaccount->setAlignment(Qt::AlignCenter);
        editaccount->resize(300,50);
        editaccount->setMaxLength(20);
        editaccount->move(labelaccount->x()+100,labelaccount->y());
    
    
        //密码图标
        QLabel *labelpwd = new QLabel(this);
        labelpwd->resize(50,50);
        //移动位置
        labelpwd->move(labelaccount->x(),labelaccount->y()+80);
        labelpwd->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\psw.png"));
        labelpwd->setScaledContents(true);
    
        //密码编辑框
        QLineEdit *editpwd = new QLineEdit(this);
        editpwd->setPlaceholderText("请输入密码");
        editpwd->setEchoMode(QLineEdit::Password);
        editpwd->setAlignment(Qt::AlignCenter);
        editpwd->resize(300,50);
        editpwd->setMaxLength(20);
        editpwd->move(editaccount->x(),editaccount->y()+80);
    
    
        //登录按钮
        QPushButton *login = new QPushButton(QIcon("D:\\learn\\QT\\day1\\work\\accept.png"),"登录",this);
        login->move(editpwd->x()+10,editpwd->y()+80);
    
        //退出按钮
        QPushButton *exit = new QPushButton(QIcon("D:\\learn\\QT\\day1\\work\\reject.png"),"登录",this);
        exit->move(editpwd->x()+180,editpwd->y()+80);
    
    
    }
    
    LoginWindow::~LoginWindow()
    {
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70

    效果

    在这里插入图片描述

  • 相关阅读:
    4061 Magic Multiplication,思维,枚举,优化
    wireshark通常无法抓取交换机所有端口报文
    Vue 组件的自定义事件
    面向需求,面向系统,物联网安全体系你知道多少?
    Python编程学习笔记
    ssh大学生银行助学贷款系统的设计与实现源码
    基于STM32和FreeRTOS的二值信号量实现任务同步
    C++模板与STL(一):模板基础与STL仿真复现
    vulnhub靶场之NOOB: 1
    3D打印喷嘴大小如何选择0.2-0.5mm喷嘴
  • 原文地址:https://blog.csdn.net/weixin_45790676/article/details/132910792