教案对齐官方方案书:重写为 5 天 C++/Qt 教学设计,补齐 6 个 Qt 技术缺口示例
- docs/teaching/OUTLINE.md、slides/day1-5.html、index.html:替换此前自定义的 4 天方案,严格对齐 docs/TRAINING_PLAN_2026.md「C++方向」Day1-5 课堂内容 (Day6-10 为纯项目实作,不在教案范围) - docs/teaching/examples/:官方方案书要求但仓库 p03/(wiki 抓取内容) 未覆盖的 QSS/Model-View/JSON/QThread/QPropertyAnimation/QStateMachine 六个技术点, 各补一个最小可运行示例 + README 教学文档,均已离屏验证跑通;手工维护, 不属于 gen_part3.py 生成产物 - 根 CMakeLists.txt:接入 docs/teaching/examples 构建(BUILD_QT_PART 分支内), 不改动生成器管理的 p01/p03 CMakeLists - 任务卡改为目标/验收标准/基础知识参考三段式模板,custom.css 配套新增样式 - docs/teaching/PRETEST.md:10 题 10 分钟 C++ 摸底测验,验证教案假定的受众 基础是否成立,并与 OUTLINE.md §0 的分层预案挂钩
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// ============================================================================
|
||||
// qt_property_animation —— 教学补充示例(非 wiki 生成,手工维护)
|
||||
// 用途:方案书「C++方向 Day4」要求的 QPropertyAnimation 动画框架,仓库 p03/
|
||||
// 原有 wiki 抓取内容未覆盖这一点,故补一个最小示例。
|
||||
// 配套文档:docs/teaching/examples/property_animation/README.md
|
||||
// 离屏验证:QT_QPA_PLATFORM=offscreen tools/run_qt.sh qt_property_animation
|
||||
// ============================================================================
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QTimer>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget window;
|
||||
window.resize(320, 200);
|
||||
|
||||
auto* button = new QPushButton(QStringLiteral("看我移动"), &window);
|
||||
button->setGeometry(10, 10, 100, 30);
|
||||
|
||||
// QPropertyAnimation 直接驱动 Qt 属性系统里的 geometry 属性,
|
||||
// 不需要手写定时器 + 逐帧计算坐标。
|
||||
auto* anim = new QPropertyAnimation(button, "geometry", &window);
|
||||
anim->setDuration(800);
|
||||
anim->setStartValue(QRect(10, 10, 100, 30));
|
||||
anim->setEndValue(QRect(180, 140, 120, 40));
|
||||
anim->setEasingCurve(QEasingCurve::OutBounce);
|
||||
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
|
||||
window.show();
|
||||
// 离屏/自动化验证:动画时长 800ms,额外等 300ms 确保播放完再退出
|
||||
QTimer::singleShot(1100, &app, &QApplication::quit);
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user