QT九月28日

1.实现登录界面

头文件

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

class Widget : public QWidget
{
    Q_OBJECT

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

源文件

#include "widget.h"
#include <QIcon>
#include <QPushButton>
#include <QLabel>
#include <QMovie>
#include <QLineEdit>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowTitle("Metal Gear Solid V");
    this->setWindowIcon(QIcon("D:/Game/1.png"));
    this->setFixedSize(600,800);
    this->setStyleSheet("background-color:black");
    QPushButton *ptr1 = new QPushButton("登录",this);
    ptr1->resize(100,40);
    ptr1->move(120,700);
    ptr1->setStyleSheet("background-color: white; color: black;");
    QPushButton *ptr2 = new QPushButton("取消",this);
    ptr2->resize(100,40);
    ptr2->move(400,700);
    ptr2->setStyleSheet("background-color: white; color: black;");
    QLabel *ptr3 = new QLabel(this);
    ptr3->resize(600,300);
    ptr3->move(0,0);
    QMovie *movie = new QMovie("D:/Game/2.gif");
    ptr3->setMovie(movie);
    movie->start();
    ptr3->setScaledContents(true);
    QLabel *ptr4 = new QLabel("账号:",this);
    ptr4->move(ptr1->x(),ptr1->y()-200);
    ptr4->resize(100,40);
    ptr4->setStyleSheet("color: white;");
    QLabel *ptr5 = new QLabel("密码:",this);
    ptr5->move(ptr1->x(),ptr1->y()-150);
    ptr5->resize(100,40);
    ptr5->setStyleSheet("color: white;");
    QLineEdit *ptr6 = new QLineEdit(this);
    ptr6->resize(300,40);
    ptr6->move(ptr4->x()+50,ptr4->y());
    ptr6->setStyleSheet("color: white;");
    QLineEdit *ptr7 = new QLineEdit(this);
    ptr7->resize(300,40);
    ptr7->move(ptr5->x()+50,ptr5->y());
    ptr7->clear();
    ptr7->setPlaceholderText("输入密码");
    ptr7->setStyleSheet("color: white;");
    ptr7->setEchoMode(QLineEdit::Password);
}
Widget::~Widget()
{
}

主函数

#include "widget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}

思维导图

相关推荐
字节全栈_rJF16 分钟前
性能测试 —— Tomcat监控与调优:status页监控_tomcat 自带监控
java·tomcat
xianwu5431 小时前
反向代理模块jmh
开发语言·网络·数据库·c++·mysql
爱编程的小新☆1 小时前
Java篇之继承
java·开发语言
Leven1995272 小时前
Flink (十三) :Table API 与 DataStream API 的转换 (一)
数据库·sql·flink
gentle coder2 小时前
Redis_Redission的入门案例、多主案例搭建、分布式锁进行加锁、解锁底层源码解析
java·redis·分布式
萝卜青今天也要开心2 小时前
读书笔记-《Redis设计与实现》(一)数据结构与对象(下)
java·数据结构·redis·学习
customer082 小时前
【开源免费】基于SpringBoot+Vue.JS景区民宿预约系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
geovindu2 小时前
neo4j-community-5.26.0 create new database
数据库·mysql·neo4j
太阳伞下的阿呆2 小时前
排查定位jar包大文件
java·centos·jar
行十万里人生2 小时前
Qt事件处理:理解处理器、过滤器与事件系统
开发语言·git·qt·华为od·华为·华为云·harmonyos