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

思维导图

相关推荐
弹简特30 分钟前
【Java项目-轻聊】01-项目演示+项目介绍+准备工作+项目源码
java
luck_bor1 小时前
File类&递归作业
java·开发语言
weixin_397574091 小时前
用自然语言查数据库出图表靠谱吗?一次智能问数实践复盘
数据库
武子康1 小时前
Java-07 深入浅出 MyBatis数据库一对多关系模型实战:表结构设计与查询实现
java·后端
字节跳动开源3 小时前
Viking AI 搜索 CLI 正式发布:会说话,就能做搜索推荐
数据库·人工智能·开源
REDcker3 小时前
Linux OverlayFS详解
java·linux·运维
Royzst3 小时前
xml知识点
java·服务器·前端
TechWJ4 小时前
数据库在公司内网,出差路上想查数据怎么办?
服务器·数据库·mariadb
我是一颗柠檬4 小时前
【MySQL全面教学】MySQL事务与ACID Day9(2026年)
数据库·后端·mysql
橙子圆1234 小时前
Redis知识9之集群
数据库·redis·缓存