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

思维导图

相关推荐
EatFan1 分钟前
一个二维码背后的系统设计:批次生成、绑定、扫码与数据统计怎么做?
java·后端·微信小程序·二维码·qrcode
白远山1 分钟前
自助健身小程序源码:架构拆解、核心链路与本地部署实战
java·架构·uni-app·需求分析
adinnet202617 分钟前
客服与工单:响应时长与满意度问数
数据库·人工智能
Lyyaoo.24 分钟前
【动态规划】【待更新】
java·数据结构·算法
我不会起名字32232 分钟前
一天一道算法题(35):电话号码的字母组合
java·数据结构·后端·python·leetcode·go·回溯
麻瓜code35 分钟前
【JUC】基础:并发模型、锁机制与 JMM
java
曹牧38 分钟前
SpringBoot: @RequestBody String
java
文人sec1 小时前
MYSQL:insert...select:为什么锁源表的所有行和间隙?怎么最快地复制一张表?
数据库·python·mysql
爱划水不秃头的程序员1 小时前
堆 栈 和常量池的关系是啥 是jvm对他们进行的划分吗
java
周GZ1 小时前
4个提问,deepseek讲解Java中的线程池
java