Files
scuc-qt-course/docs/teaching/examples/mainwindow_showcase/main.cpp
T
张宗平 05a685c952 Day3 教学示例:增强版计算器接入 + QMainWindow/QSS 两版参考实现
- calculator_designer_ext(Day2 增强版:表达式求值 + 括号,递归下降解析器)接入 cmake
- calculator_mainwindow(Day3 上午):增强版计算器装进 QMainWindow,
  菜单/状态栏/历史停靠窗,纯代码 + 显式 connect,与 mainwindow_showcase 形成坑卡对照
- calculator_mainwindow_qss(Day3 下午):上午版 + QSS 双主题美化(按键分色/伪状态/深浅切换)
- 验证 mainwindow_showcase(QMainWindow 六大组件综合演示,.ui + .qrc)
- OUTLINE_4DAY.md / ASSIGNMENTS.md Day3 衔接增强版起点 + 参考实现指引
- 补提交 Day2 calculator/ 与 calculator_designer/ 参考实现(CMakeLists 已引用)
- 全量构建 28/28,4 目标离屏自测退出码 0

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 22:59:05 +08:00

23 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ============================================================================
// mainwindow_showcase —— QMainWindow 教学综合示例(程序入口)
// 覆盖 wiki「5 QMainWindow」(pageId 58954529) 的 5.15.6 全部六大组件:
// 5.1 菜单栏 · 5.2 工具栏 · 5.3 状态栏 · 5.4 浮动窗口 · 5.5 中心部件 · 5.6 资源文件
// 形态:极简文本编辑器(QTextEdit 为中心部件),纯组件演示,无文件 I/O。
// ============================================================================
#include <QApplication>
#include <QTimer>
#include "mainwindow_showcase.h"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
MainWindow w;
w.show();
// 仅在离屏自动化验证时(QT_QPA_PLATFORM=offscreen200ms 后自动退出;
// 正常运行(有显示环境)窗口保持打开,不自动退出。仿 p03/ch05 风格。
if (qgetenv("QT_QPA_PLATFORM") == "offscreen") {
QTimer::singleShot(200, &app, &QApplication::quit);
}
return app.exec();
}