QT作业day2

自由发挥登录窗口的应用场景,实现一个登录窗口界面。(不要使用课堂上的图片和代码,自己发挥,有利于后面项目的完成)

要求:

  1. 需要使用Ui界面文件进行界面设计

  2. ui界面上的组件相关设置,通过代码实现

  3. 需要添加适当的动图

核心代码:

cpp 复制代码
#include "game_register.h"
#include "ui_game_register.h"

game_register::game_register(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::game_register)
{
    ui->setupUi(this);

                          //设置窗口
    this->setFixedSize(800,600);//固定窗口大小
    this->setWindowTitle("崩坏星穹铁道");//设置标题
    this->setWindowIcon(QIcon(":/photograph/starry sky.jpg"));//设置图标
    this->setStyleSheet("background-color:rgb(123,246,235)");//设置背景颜色

                        //标签相关设置
    //设置背景标签一
    ui->background_1->resize(800,300);//设置大小
    ui->background_1->move(0,0);//移动
    QMovie *mv = new QMovie(":/photograph/danheng.gif");//设置动态图片
    ui->background_1->setMovie(mv);//将动态图片放进背景标签一中
    mv->start();//让动态图动起来
    ui->background_1->setScaledContents(true);//自动适应


    //设置密码标签
    ui->user_label->resize(50,50);//设置大小
    ui->user_label->move(250,340);//移动
    ui->user_label->setPixmap(QPixmap(":/photograph/user.png"));//设置图片
    ui->user_label->setScaledContents(true);//自动适应

    //设置密码标签
    ui->passwd_label->resize(50,50);//设置大小
    ui->passwd_label->move(250,420);//移动
    ui->passwd_label->setPixmap(QPixmap(":/photograph/passwd.jpg"));//设置图片
    ui->passwd_label->setScaledContents(true);//自动适应

                        //行编辑器相关设置
    //设置账号行编辑器
    ui->user_edit->resize(200, 50);
    ui->user_edit->move(320,340);
    ui->user_edit->setStyleSheet("background-color:rgb(255,255,255)");
    ui->user_edit->setPlaceholderText("账号/手机号/邮箱号"); //占位

    //设置账号行编辑器
    ui->passwd_edit->resize(200, 50);
    ui->passwd_edit->move(320,420);
     ui->passwd_edit->setStyleSheet("background-color:rgb(255,255,255)");
    ui->passwd_edit->setEchoMode(QLineEdit::Password);//设置密码掩盖
    ui->passwd_edit->setPlaceholderText("密码"); //占位

                    //按钮设置
    ui->Button->setText("登录");//设置文本
    ui->Button->resize(160,50);
    ui->Button->move(320,520);
    ui->Button->setStyleSheet("background-color:rgb(31,200,253);border-radius:10px;color:white");//设置按钮背景颜色,倒角,字体颜色


}

game_register::~game_register()
{
    delete ui;
}

思维导图

相关推荐
用户805533698031 天前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner1 天前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz6 天前
QML Hello World 入门示例
qt
xcyxiner9 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner10 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner10 天前
DicomViewer (添加模型类)3
qt
xcyxiner11 天前
DicomViewer (目录调整) 2
qt
xcyxiner11 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR00613 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术13 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript