From b33e7bda36be2ca9ea35a10a381763bf6c3a1e03 Mon Sep 17 00:00:00 2001 From: DevWiki Date: Sat, 29 Jul 2023 21:53:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 8 +++++++- mainwindow.cpp | 6 ++++++ mainwindow.h | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fd3e533..af676c2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,17 @@ +// 引入mainwindow的头文件 #include "mainwindow.h" - +// 引入 QAppliction #include int main(int argc, char *argv[]) { + // 实例化一个 QApplication对象 QApplication a(argc, argv); + // 实例化主窗口 MainWindow w; + // 显示主窗口 w.show(); + // 返回App执行结果 return a.exec(); } + diff --git a/mainwindow.cpp b/mainwindow.cpp index a06fc8e..932cf59 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,10 +1,16 @@ #include "mainwindow.h" #include "./ui_mainwindow.h" +/** + * 构造一个主窗口 + * @brief MainWindow::MainWindow + * @param parent 父Widget + */ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { + //设置Ui组件 ui->setupUi(this); } diff --git a/mainwindow.h b/mainwindow.h index 4643e32..28a911e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -7,6 +7,10 @@ QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE +/** + * 主窗口继承自QMainWindow + * @brief The MainWindow class + */ class MainWindow : public QMainWindow { Q_OBJECT