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

思维导图

相关推荐
想摆烂的不会研究的研究生1 小时前
每日八股——Redis(1)
数据库·经验分享·redis·后端·缓存
码熔burning1 小时前
MySQL 8.0 新特性爆笑盘点:从青铜到王者的骚操作都在这儿了!(万字详解,建议收藏)
数据库·mysql
毕设源码-郭学长1 小时前
【开题答辩全过程】以 基于SpringBoot技术的美妆销售系统为例,包含答辩的问题和答案
java·spring boot·后端
猫头虎1 小时前
2025最新OpenEuler系统安装MySQL的详细教程
linux·服务器·数据库·sql·mysql·macos·openeuler
梨落秋霜1 小时前
Python入门篇【文件处理】
android·java·python
Java 码农2 小时前
RabbitMQ集群部署方案及配置指南03
java·python·rabbitmq
哈库纳玛塔塔2 小时前
放弃 MyBatis,拥抱新一代 Java 数据访问库
java·开发语言·数据库·mybatis·orm·dbvisitor
S***q3773 小时前
Spring Boot管理用户数据
java·spring boot·后端
天“码”行空3 小时前
java面向对象的三大特性之一多态
java·开发语言·jvm
毕设源码-郭学长3 小时前
【开题答辩全过程】以 基于SpringBoot框架的民俗文化交流与交易平台的设计与实现为例,包含答辩的问题和答案
java·spring boot·后端