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;
}

思维导图

相关推荐
郑州光合科技余经理5 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1235 天前
matlab画图工具
开发语言·matlab
dustcell.5 天前
haproxy七层代理
java·开发语言·前端
norlan_jame5 天前
C-PHY与D-PHY差异
c语言·开发语言
多恩Stone5 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
QQ4022054965 天前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
遥遥江上月5 天前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
m0_531237175 天前
C语言-数组练习进阶
c语言·开发语言·算法
Railshiqian5 天前
给android源码下的模拟器添加两个后排屏的修改
android·开发语言·javascript
雪人不是菜鸡5 天前
简单工厂模式
开发语言·算法·c#