untitled.pro
//Qt 包含的模块
QT += core gui
//大于4版本以上包含 widget 模块
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
//目标 模板生成的.exe程序的名称
TARGET = untitled_second
//模板 应用程序模板 Application
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as 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 you use 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 \ //源文件
mainwindow.cpp
HEADERS += \
mainwindow.h //头文件
FORMS += \
mainwindow.ui
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
//包含头文件 QMainWindow 窗口类
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT //Q_OBJECT宏,允许类中使用信号和槽的机制
public:
explicit MainWindow(QWidget *parent = 0); //构造函数
~MainWindow(); //析构函数
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
// 命名规范
// 类名 首字母大写,单词和单词之间首字母大写
// 函数名 变量名称 首字母小写, 单词和单词之间首字母大写
// 快捷键
// 注释 Ctrl + /
// 运行 Ctrl + r
// 编译 Ctrl + b
// 字体缩放 Ctrl +鼠标滚轮
// 查找 Ctrl + l
// 整行移动 Ctrl + shift + 1或者的 l
// 帮助文档 F1
// 自动对齐 Ctrl + i
// 同名之间的 .h 和 cpp 切换 F4
//帮助文档 第一种方式 F1 第二种 左键按钮 第三种 C:\Qt\Qt5.9.0\5.9\mingw53_32\bin\assistant.exe