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()
{
}
相关推荐
Dev7z16 分钟前
基于Matlab多目标粒子群优化的无人机三维路径规划与避障研究
开发语言·matlab·无人机
沐知全栈开发39 分钟前
HTML 脚本:基础、应用与未来趋势
开发语言
温宇飞43 分钟前
C++ 内存与性能优化:语言特性的开销分析与替代方案
c++
@菜菜_达1 小时前
interact.js 前端拖拽插件
开发语言·前端·javascript
APIshop1 小时前
实战解析:苏宁易购 item_search 按关键字搜索商品API接口
开发语言·chrome·python
百***92021 小时前
java进阶1——JVM
java·开发语言·jvm
蓝桉~MLGT1 小时前
Python学习历程——Python面向对象编程详解
开发语言·python·学习
Evand J2 小时前
【MATLAB例程】2雷达二维目标跟踪滤波系统-UKF(无迹卡尔曼滤波)实现,目标匀速运动模型(带扰动)。附代码下载链接
开发语言·matlab·目标跟踪·滤波·卡尔曼滤波
larance2 小时前
Python 中的 *args 和 **kwargs
开发语言·python
Easonmax2 小时前
用 Rust 打造可复现的 ASCII 艺术渲染器:从像素到字符的完整工程实践
开发语言·后端·rust