2024.05.06作业

自由发挥应用场景,实现登录界面。

要求:尽量每行代码都有注释。

cpp 复制代码
#include "yuanshen.h"

yuanshen::yuanshen(QWidget *parent)
    : QWidget(parent)
{
    //==============窗口相关设置=======
    this->resize(1600,910);
    this->setFixedSize(1600,910);


    //窗口标题
    this->setWindowTitle("原神 4.0");
    //窗口图标
    this->setWindowIcon(QIcon("C:\\Users\\ShiSS\\Desktop\\pictrue\\logo.jpg"));
    //背景颜色
    this->setStyleSheet("background-color:rgb(20,20,20)");
    //去掉头部
    this->setWindowFlag(Qt::FramelessWindowHint);

    //============标签相关设置=======
    QLabel *lab3 = new QLabel("原神 ",this);
    //设置大小
    lab3->resize(40,40);
    //标签移动
    lab3->move(20,0);
    //标签字体颜色
    lab3->setStyleSheet("color:rgb(225,225,225)");


    QLabel *lab2 = new QLabel(" 4.0.0",this);
    lab2->resize(60,40);
    lab2->move(60,0);
    lab2->setStyleSheet("color:rgb(60,60,60)");

    //主体背景图
    QLabel *lab=new QLabel(this);
    lab->resize(1600,870);
    lab->move(0,35);
    lab->setPixmap(QPixmap("C:\\Users\\ShiSS\\Desktop\\pictrue\\40.jpg"));
    //自动适应
    lab->setScaledContents(true);

    //============按钮相关设置=======
    QPushButton *btn1=new QPushButton("开始游戏",this);
    //设置大小
    btn1->resize(255,80);
    //按钮移动
    btn1->move(1145,720);
    //按钮背景颜色
    btn1->setStyleSheet("background-color:rgb(255,199,8);border-radius:5px;color:rgb(119,76,33)");

    QPushButton *btn2=new QPushButton("三",this);
    //设置大小
    btn2->resize(50,80);
    //按钮移动
    btn2->move(1400,720);
    //按钮背景颜色
    btn2->setStyleSheet("background-color:rgb(255,199,8);border-radius:5px;color:rgb(148,106,24)");

    QFont font;
    font.setFamily("Arial");
    font.setPointSize(20);
    font.setBold(true);
    // 设置按钮的字体
    btn1->setFont(font);
}

yuanshen::~yuanshen()
{
}
相关推荐
adsadswee5 小时前
Qt 样式与 QLinearGradient 渐变详解
开发语言·qt·qt样式表·qlineargradient·qss渐变效果
feiyangqingyun6 小时前
Qt优化onvif设备搜索/一键批量搜索/onvif设备模拟器/几千路并发/实时推流/虚拟监控摄像头
qt·onvif模拟器
wd_cloud7 小时前
QT/6.7.2/Creator编译Windows64 MySQL驱动
开发语言·qt·mysql
Source.Liu12 小时前
【LibreCAD】LC_UndoSection 类详解
qt·cad
27399202912 小时前
qt 获取IP地址(公网 本机)
qt·tcp/ip·php
ULTRA??14 小时前
QT向量实现GJK碰撞检测算法几何图形二维版本
c++·qt·算法
我要升天!14 小时前
QT -- QSS界面优化
开发语言·c++·qt
lenkco17 小时前
修改QtConcurrent::run支持任意参数
开发语言·c++·qt
葱卤山猪17 小时前
【Qt】 TCP套接字通信学习文档
qt·学习·tcp/ip
ULTRA??17 小时前
QT向量类实现GJK碰撞检测算法3d版本
c++·qt·算法