0
点赞
收藏
分享

微信扫一扫

微信超实用的隐藏功能:群发上千人,定时发圈,自动回复,一键转发朋友圈

ZGtheGreat 09-18 23:30 阅读 1
qt

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

效果

在这里插入图片描述

举报

相关推荐

0 条评论