QTDAY1

2024-01-08 20:33:15

?头文件

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QIcon>
#include <QLabel>
#include <QMovie>
#include <QLineEdit>
#include <QPushButton>
class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
};
#endif // WIDGET_H

?设计界面

#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //设置窗口
    this->setWindowTitle("GTA5");
    this->setWindowIcon(QIcon("C:\\Users\\22249\\Desktop\\1\\pictrue\\gta.jfif"));
    this->setFixedSize(680,480);
    this->setStyleSheet("background-color:rgb(255,255,255)");
    this->setWindowFlags(Qt::FramelessWindowHint);


    //设置标签
    //整个背景
    QLabel *lab1=new QLabel(this);
    lab1->resize(680,480);
    lab1->setPixmap(QPixmap("C:\\Users\\22249\\Desktop\\1\\pictrue\\gta_login.jpg"));
    lab1->setScaledContents(true);

    //R星logo
    QLabel *lab2=new QLabel(this);
    lab2->resize(60,60);
    lab2->move(10,10);
    lab2->setPixmap(QPixmap("C:\\Users\\22249\\Desktop\\1\\pictrue\\rxing.png"));
    lab2->setScaledContents(true);
    lab2->setStyleSheet("border-radius:10px");

    //账户登录
    QLabel *lab3=new QLabel(this);
    lab3->resize(90,65);
    lab3->move(170,130);
    QMovie *mv=new QMovie("C:\\Users\\22249\\Desktop\\1\\pictrue\\cxk.gif");
    lab3->setMovie(mv);
    mv->start();
    lab3->setScaledContents(true);

    //设置行编辑器
    QLineEdit *edit1=new QLineEdit(this);
    edit1->move(80,200);
    edit1->resize(275,30);
    edit1->setPlaceholderText("账号/邮箱");

    QLineEdit *edit2=new QLineEdit(this);
    edit2->move(80,240);
    edit2->resize(275,30);
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);

    //设置按钮
    QPushButton *btn1=new QPushButton("登录",this);
    btn1->move(90,300);
    btn1->resize(255,40);
    btn1->setStyleSheet("background-color:rgb(255,170,0);border-radius:10px;color:white");

    QPushButton *btn2=new QPushButton("关闭",this);
    btn2->move(640,0);
    btn2->resize(40,30);
    btn2->setStyleSheet("background-color:rgb(255,0,0);color:white");
}

Widget::~Widget()
{
}

效果图?

?

?

文章来源:https://blog.csdn.net/2301_79218085/article/details/135464996
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。