注释:
.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget> // 防止头文件重复包含
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }  
//Ui表示命名空间的名称
//{ class Widget; } :表示在Ui命名空间中声明一个其他文件midget的类
QT_END_NAMESPACE
//QT_BEGIN_NAMESPACE  QT_END_NAMESPACE :用于管理QT命名空间的宏,避免命名冲突
class Widget : public QWidget
//对自定义类的声明,公共继承了QWidget QWidget封装了有关图形化界面的相关功能
{
    Q_OBJECT  //宏 表示信号与曹的元素对象,
public:
    Widget(QWidget *parent = nullptr); //构造函数的声明
    ~Widget(); //析构函数的声明   虚析构函数
private:
    Ui::Widget *ui;   //成员指针
};
#endif // WIDGET_H
main.cpp
#include "widget.h"
//文件包含,自定义的头文件,该头文件包含了图形化界面类
#include <QApplication>//包含应用程序的头文件
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);//应用成员类实例化对象,调用有参构造
    Widget w;//使用自定义的类调用无参构造在栈区构造一个界面对象
    w.show(); //调用对象的成员函数,将界面展示出来
    return a.exec(); //应用程序类对象,调用应用程序的成员函数,保证界面不被关闭,轮寻等待界面上的时间发生
    
}
.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)  //构造函数定义
    : QWidget(parent)  //在子类的初始化列表中显示调用父类的有参构造,来完成对子类从父类的继承
    , ui(new Ui::Widget) //给自己的类中的指针成员实例化空间
{
    ui->setupUi(this); //将UI界面的组件展示在this界面上
}
Widget::~Widget()  //析构函数的定义
{
    delete ui;  //释放UI界面的组件空间
}
.pro
QT       += core gui
#引用的QT的类库,core:表示核心库 gui:表示图形优化库
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#greaterThan:这是QT的内置函数,用于比较两个值  QT_MAJOR_VERSION:是个宏定义表示QT版本号  4:在上下文中表示QT的主板本号 
#QT:指定要链接的QT模版  widgets:QT模版用于提供创建图形用户界面的功能
#整体:表示如果QT的版本大于4,将widgets的模版添加到项目中
CONFIG += c++11 #表示支持C++的版本号为11版本
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
#表示 是一种用于提高代码质量和维护性的编译指令,通过启用对已弃用功能的警告,帮助开发者及时更新和维护代码。
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \        #实现项目的管理
    main.cpp \      #表示要管理的源文件
    widget.cpp
HEADERS += \        #管理头文件
    widget.h        #管理的头文件
FORMS += \          #管理所以的UI文件
    widget.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
登录框
#include "widget.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->setFixedSize(400,500);//设置当前界面尺寸
   // this->setStyleSheet("D:/tubiao/640.gif");//这种背景颜色为粉色
    QLabel *ptr3 = new QLabel(this);
        ptr3->resize(400,500);
        ptr3->move(0,0);
        QMovie *movie = new QMovie("D:/tubiao/640.gif");
        ptr3->setMovie(movie);
        movie->start();
        ptr3->setScaledContents(true);
   //使用QIcon实例化一个对象
    QIcon icon("D:/tubiao/icon_6dj6gprvzoq/icon_6dj6gprvzoq/tubiao-_4.png");
    this->setWindowIcon(icon);//跟换图标
    this->setWindowTitle("QQ"); //跟换窗口标题
    QPushButton * btn1=new QPushButton;
    QPushButton *btn2=new QPushButton(this);
    QPushButton *btn3=new QPushButton("登录",this);
    QPushButton *btn4=new QPushButton("注册",this);
    btn1->setParent(this); // 将当前界面设置成组件的父组件
  //  btn1->setStyleSheet("clor:white;background:skyblue;border-radius:10px;");
    btn1->setText("账号:");   //设置按钮文本内容
    btn1->resize(60,35);    //  重新设置尺寸
    btn1->move(50,150);        //移动当前按钮
  //  btn2->setStyleSheet("clor:white;background:skyblue;border-radius:10px;");
    btn2->setText("密码:");   //设置按钮文本内容
    btn2->resize(btn1->size());    //  重新设置尺寸
    btn2->move(50,200);   //移动当前按钮
   // btn3->setStyleSheet("clor:white;background:skyblue;");
    btn3->resize(btn2->size());    //  重新设置尺寸
    btn3->move(100,250);   //移动当前按钮
    btn4->resize(btn3->size());    //  重新设置尺寸
    btn4->move(200,250);   //移动当前按钮
    QLineEdit *edit1=new QLineEdit(this);
    QLineEdit *edit2=new QLineEdit(this);
    edit1->resize(200,35);
    edit2->resize(200,35);
    edit1->setPlaceholderText("请输入账号");
    edit2->setPlaceholderText("请输入密码");
    edit2->setEchoMode(QLineEdit::Password);
    edit1->move(110,150);
    edit2->move(110,200);
}
Widget::~Widget()
{
}


![LeetCode[中等] 17. 电话号码的字母组合](https://i-blog.csdnimg.cn/direct/379252bcc4684e7a8a609be563d80bb1.png)

















