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()
{
}
相关推荐
froginwe111 分钟前
SQLite Indexed By
开发语言
虾说羊2 分钟前
JVM 高频面试题全解析
java·开发语言·jvm
毕设源码-赖学姐15 分钟前
【开题答辩全过程】以 基于PHP的国学诗词网站与推荐系统的设计与实现为例,包含答辩的问题和答案
开发语言·php
盼哥PyAI实验室15 分钟前
[特殊字符]️ 实战爬虫:Python 抓取【采购公告】接口数据(含踩坑解析)
开发语言·爬虫·python
wjs202419 分钟前
PostgreSQL NULL 值处理与优化
开发语言
prettyxian22 分钟前
【QT】Qt从零入门指南:创建你的第一个GUI程序
开发语言·qt
AllinLin29 分钟前
javaScript学习计划(Day26-30)
开发语言·javascript·学习
Wang153031 分钟前
c++与Java谁的性能更胜一筹
java·c++
代码游侠32 分钟前
应用——Linux Socket编程
运维·服务器·开发语言·笔记·网络协议·学习
ss27335 分钟前
Java定时任务:ScheduledThreadPoolExecutor
开发语言·python