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()
{
}
相关推荐
卜锦元6 分钟前
Go中使用wire进行统一依赖注入管理
开发语言·后端·golang
卡卡_R-Python19 分钟前
C++编程基础
c++
军训猫猫头36 分钟前
3.检查函数 if (!CheckStart()) return 的妙用 C#例子
开发语言·c#
coding随想38 分钟前
JavaScript中的系统对话框:alert、confirm、prompt
开发语言·javascript·prompt
灵哎惹,凌沃敏38 分钟前
C语言/Keil的register修饰符
c语言·开发语言
Azxcc01 小时前
C++迭代器失效
开发语言·c++
0wioiw01 小时前
Flutter基础(前端教程⑤-组件重叠)
开发语言·前端·javascript
嘉琪0012 小时前
2025 js——面试题(7)——ajax相关
开发语言·javascript·ajax