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()
{
}
相关推荐
共享家95275 小时前
QT-常用控件(一)
开发语言·qt
ajassi20006 小时前
开源 C++ QT QML 开发(十二)通讯--TCP客户端
c++·qt·开源
nnnnichijou7 小时前
Qt Quick 3D-机械臂模型显示与交互
qt·3d·交互
长源Gingko10 小时前
Windows中在QTCreator中调试,提示缺少debug information files问题的解决
windows·qt
SundayBear12 小时前
Qt 开发修炼指南:从入门到通透的实战心法
开发语言·qt·嵌入式
ajassi200012 小时前
开源 C++ QT QML 开发(十)通讯--串口
c++·qt·开源
BingeBlog13 小时前
[01] Qt的UI框架选择和对比
开发语言·c++·笔记·qt·ui·开源软件
扶尔魔ocy17 小时前
【QT常用技术讲解】opencv实现摄像头图像检测并裁剪物体
开发语言·qt·opencv
ajassi20001 天前
开源 C++ QT QML 开发(二)工程结构
linux·qt·qml
楼田莉子1 天前
Qt开发学习——QtCreator深度介绍/程序运行/开发规范/对象树
开发语言·前端·c++·qt·学习