qt实现登录界面
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//设置纯净窗口
this->setWindowFlag(Qt::FramelessWindowHint);
//重新设置窗口的大小以及不可改变
this->resize(533,450);
this->setFixedSize(533,450);
//接收动图并设置
QMovie *mv=new QMovie(":/homework/2013dade60710e6f719a008dc47138b7.gif");
//设置标签里面的动图以及自己适应
ui->BackPicture->resize(533,200);
ui->BackPicture->setMovie(mv);
mv->start();
ui->BackPicture->setScaledContents(true);
//设置底层的背景图,当按下登录后隐藏背景1
ui->BackPicture_2->resize(533,200);
ui->BackPicture_2->setPixmap(QPixmap(":/homework/5a51f62e8b1d6961e7a6e663a9c4e14.jpg"));
ui->BackPicture->setScaledContents(true);
//设置输入框旁边的图标
ui->Qicon->resize(50,50);
ui->Qicon->move(100,230);
ui->Qicon->setPixmap(QPixmap(":/homework/OIP-C.jpg"));
ui->Qicon->setScaledContents(true);//设置图片适应图标
ui->Qicon_2->resize(50,50);
ui->Qicon_2->move(100,280);
ui->Qicon_2->setPixmap(QPixmap(":/homework/R-C.jfif"));
ui->Qicon_2->setScaledContents(true);//设置图片适应图标
//设置用户名行编辑器
ui->UserName->resize(300,50);
ui->UserName->move(150,230);
ui->UserName->setPlaceholderText("喵喵账号");
//设置密码行编辑器
ui->Passwd->resize(300,50);
ui->Passwd->move(150,280);
ui->Passwd->setPlaceholderText("喵喵密码");
ui->Passwd->setEchoMode(QLineEdit::Password);
//设置登录按钮
ui->LoginBut->resize(50,50);
ui->LoginBut->move(200,340);
ui->LoginBut->setStyleSheet("background-color:pink;border-radius:25px");
ui->LoginBut->setText("登录");
//设置注册按钮
ui->ReginBut->resize(50,50);
ui->ReginBut->move(280,340);
ui->ReginBut->setStyleSheet("background-color:rgb(156,222,251);border-radius:25px");
ui->ReginBut->setText("注册");
}
MainWindow::~MainWindow()
{
delete ui;
}
按下登录按钮,隐藏背景1