12.7 C++作业

自由发挥登录窗口的应用场景,实现一个登录窗口界面

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

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //*******窗口相关设置********
    this->setWindowTitle("王者农药");  //设置窗口标题
    this->setWindowIcon(QIcon("C:\\Users\27119\\Pictures\\QT\\pictrue\\R-C.png")); //设置窗口图标
    //设置纯净窗口(去掉头部)
    this->setWindowFlags(Qt::FramelessWindowHint);
    //重新设置窗口大小
    this->resize(740,540);
    //设置背景图颜色
    this->setStyleSheet("background-color:rgb(86,198,220)");

    //*******标签相关设置********
    QLabel *lab1 = new QLabel(this);
    lab1->resize(740,280); //设置标签大小
    lab1->setStyleSheet("background-color:rgb(178,191,229)"); //标签背景颜色

    //动图类 接收动图
    QMovie *mv = new QMovie("C:\\Users\\27119\\Pictures\\QT\\pictrue\\R-B.gif");
    //将动图放入label中
    lab1->setMovie(mv);
    //让动图动起来
    mv->start();
    //自适应labl
    lab1->setScaledContents(true);

    QLabel *lab2 = new QLabel(this);   //第二个标签
    lab2->move(25,40); //移动标签
    lab2->resize(80,35);  //设置图标大小
    lab2->setPixmap(QPixmap("C:\\Users\\27119\\Pictures\\QT\\pictrue\\R-D.png")); //将标签图放入
    lab2->setScaledContents(true); //自适应lab2

    QLabel *lab3 = new QLabel(this);  //设置第三个账号标签
    lab3->move(160,330); //移动位置
    lab3->resize(30,30); //设置大小
    lab3->setPixmap(QPixmap("C:\\Users\\27119\\Pictures\\QT\\pictrue\\userName.jpg"));
    lab3->setScaledContents(true); //自适应lab3

    QLabel *lab4 = new QLabel(this);  //设置密码标签
    lab4->move(160,390); //移动位置
    lab4->resize(30,30);  //设置大小
    lab4->setPixmap(QPixmap("C:\\Users\\27119\\Pictures\\QT\\pictrue\\passwd.jpg"));
    lab3->setScaledContents(true); //自适应lab4

    QLabel *lab5 = new QLabel(this);
    lab5->resize(60,60); //设置大小
    lab5->move(350,260);
    lab5->setPixmap(QPixmap("C:\\Users\\27119\\Pictures\\QT\\pictrue\\R-C.png"));
    lab5->setScaledContents(true);

    //*******标签相关设置********
    QLineEdit *edit1 = new QLineEdit(this);
    edit1->move(200,330);  //移动
    edit1->resize(350,40);   //设置大小
    edit1->setPlaceholderText("QQ号码"); //占位

    QLineEdit *edit2 = new QLineEdit(this);
    edit2->move(200,390);  //移动
    edit2->resize(350,40);   //设置大小
    edit2->setPlaceholderText("QQ密码"); //占位
    edit2->setEchoMode(QLineEdit::Password); //设置显示

    //*******按钮相关设置********
    QPushButton *btn1 = new QPushButton(this);
    btn1->resize(320,45); //设置大小
    btn1->move(200,450);  //移动
    btn1->setStyleSheet("background-color:rgb(235,180,50);borden-radius:10px"); //设置颜色和弧度
    btn1->setText("开始游戏");   //设置文本


}

Widget::~Widget()
{
}
相关推荐
小新讲网安3 分钟前
WiFi安全攻防实战:WPA3新协议与传统破解技术全解析
开发语言·网络·安全·php·漏洞·nmap·漏洞检测
必须会一定会6 小时前
Agent Plugins 1.0实战:plugin.json、skills、mcp.json目录结构与迁移
开发语言·人工智能·ai编程
St_rive6 小时前
Page Object设计模式
java·开发语言·设计模式
wp123_16 小时前
硬件元器件笔记|IPX8 防水 Type‑C 母座安费诺 124018802112A 与 TONEVEE TY48086‑24A 分析
c语言·开发语言·笔记
wuyk5556 小时前
4.树:一对多的层次数据结构
开发语言·数据结构·stm32·单片机
luj_17687 小时前
桥牌思维启示:系统设计的模块化架构
c语言·开发语言·c++·经验分享·算法
会周易的程序员8 小时前
aiDgePLC iec61131 虚拟机 完整使用文档
c++·物联网·架构·st·iec61131
小小龙学IT9 小时前
Boost.Beast 深度实战:基于 Asio 的开源 C++ HTTP/WebSocket 协议库
c++·websocket·http
caimouse9 小时前
ReactOS 图形系统分析(16):字符串对象 — STROBJ(string.c)
c语言·开发语言