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()
{
}
相关推荐
阿正的梦工坊16 小时前
JavaScript 微任务与宏任务完全指南
开发语言·javascript·ecmascript
知行合一。。。17 小时前
Python--05--面向对象(属性,方法)
android·开发语言·python
自信1504130575917 小时前
重生之从0开始学习c++之模板初级
c++·学习
青梅橘子皮17 小时前
C语言---指针的应用以及一些面试题
c语言·开发语言·算法
浅时光_c17 小时前
3 shell脚本编程
linux·开发语言·bash
历程里程碑17 小时前
2. Git版本回退全攻略:轻松掌握代码时光机
大数据·c++·git·elasticsearch·搜索引擎·github·全文检索
极客智造17 小时前
深度解析 C++ 类继承与多态:面向对象编程的核心
c++
Evand J18 小时前
【三维轨迹目标定位,CKF+RTS,MATLAB程序】基于CKF与RTS平滑的三维非线性目标跟踪(距离+方位角+俯仰角)
开发语言·matlab·目标跟踪
今天又在写代码18 小时前
java-v2
java·开发语言
competes19 小时前
慈善基金投资底层逻辑应用 顶层代码低代码配置平台开发结构方式数据存储模块
java·开发语言·数据库·windows·sql