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();
}

思维导图

相关推荐
叽哥11 分钟前
Kotlin学习第 9 课:Kotlin 实战应用:从案例到项目
android·java·kotlin
阿杆1 小时前
同事嫌参数校验太丑,我直接掏出了更优雅的 SpEL Validator
java·spring boot·后端
DemonAvenger1 小时前
NoSQL与MySQL混合架构设计:从入门到实战的最佳实践
数据库·mysql·性能优化
Grey Zeng10 小时前
Java SE 25新增特性
java·jdk·jdk新特性·jdk25
雨白11 小时前
Java 线程通信基础:interrupt、wait 和 notifyAll 详解
android·java
AAA修煤气灶刘哥13 小时前
后端人速藏!数据库PD建模避坑指南
数据库·后端·mysql
架构师沉默15 小时前
设计多租户 SaaS 系统,如何做到数据隔离 & 资源配额?
java·后端·架构
Java中文社群17 小时前
重要:Java25正式发布(长期支持版)!
java·后端·面试
RestCloud17 小时前
揭秘 CDC 技术:让数据库同步快人一步
数据库·api
每天进步一点_JL18 小时前
JVM 类加载:双亲委派机制
java·后端