13b3ebbe14
把川大 wiki「02.Qt方向」课程代码整理为 CMake 管理的可编译运行项目。
Part1 C/C++ 强化 (p01/, 144 目标, host gcc/g++ 构建, 全绿):
- 修复全部编译失败:补 <cstring>/<fstream>/<iomanip>/<vector> 等缺失头
(common_fix + infer_stl_includes 自动检测注入)、修正 pause() 壳注入
(改检测已转换后的 pause 调用)、namespace 提升出函数体、const 成员函数
正确性、dedupe 不再破坏函数重载集、K&R 隐式 int / 动态异常规范等
C++17 移除特性的可编译等价改写。
- 目录采用深缩写 p01/ch04/s03/ (原 part1_cpp/ch04_class_object/03_ctor_dtor)。
Part3 Qt 桌面 (p03/, 29 目标, 隔离 Qt 5.14.2 构建, 全绿):
- gen_part3.py: Qt 外壳模板 (main+QApplication+show, QTimer 自动退出便于
offscreen 验证)、AUTOMOC + .moc include、rewrite_* 处理散文混入/重载/
资源依赖、生成占位 png/gif + .qrc + rundata 样例数据。
- 修正 QLable 笔误、全角分号、.→->、Windows 路径、QApplication 阻塞事件
循环改为 QCoreApplication 等。
任务1 概念/版本验证:
- tools/std_probe.py: 跨 -std= 编译探针 (--pedantic-errors 让已废除特性硬失败)。
- tools/demo_versions/: K&R 隐式 int、三目左值、void* 转换、enum 赋整、
const 经指针、动态异常规范 共 6 个跨版本演示。
- docs/VERSION_NOTES.md: 每条「原文说法→C17/C++17 是否成立→何版本成立→已验证」。
文档: 顶层 README、docs/SOURCE_PAGES.md (页面→目录映射)、
docs/ERRATA.md (Part1 修正)、docs/ERRATA_part3.md (Part3 修正)。
另修复 tools/run.sh / run_qt.sh 的 ${1:?...} 引号语法 bug。
隔离 Qt 验证: ldd 0 系统 Qt 引用; 173/173 目标全绿; p03 offscreen 运行通过。
1 line
9.6 KiB
JSON
1 line
9.6 KiB
JSON
{"id":"58954500","type":"page","status":"current","title":"02.QT安装教程(免注册和登陆)","version":{"by":{"type":"known","username":"suncaper","userKey":"ff80818177bd0eb50179c1060d480003","profilePicture":{"path":"/images/icons/profilepics/default.svg","width":48,"height":48,"isDefault":true},"displayName":"suncaper","_links":{"self":"https://wiki.suncaper.net/rest/api/user?key=ff80818177bd0eb50179c1060d480003"},"_expandable":{"status":""}},"when":"2025-07-03T04:13:50.738Z","message":"","number":6,"minorEdit":false,"hidden":false,"_links":{"self":"https://wiki.suncaper.net/rest/experimental/content/58954500/version/6"},"_expandable":{"content":"/rest/api/content/58954500"}},"body":{"storage":{"value":"<p>准备工作: 第一步: 环境安装</p><p>下载安装包,可以到Qt官网,但是下载速度非常慢。一般推荐到几个国内著名的 Qt 镜像网站下载:</p><ul class=\" list-paddingleft-2\" style=\"text-align: justify;\"><li><p><span><span style=\"color: rgb(68,68,68);\">中国科学技术大学:</span><span style=\"color: rgb(0,125,187);\"><a href=\"http://mirrors.ustc.edu.cn/qtproject/\">http://mirrors.ustc.edu.cn/qtproject/</a></span></span></p></li><li><p><span><span style=\"color: rgb(68,68,68);\">清华大学:</span><span style=\"color: rgb(0,125,187);\"><a href=\"https://mirrors.tuna.tsinghua.edu.cn/qt/\">https://mirrors.tuna.tsinghua.edu.cn/qt/</a></span></span></p></li><li><p><span><span style=\"color: rgb(68,68,68);\">北京理工大学:</span><span style=\"color: rgb(0,125,187);\"><a href=\"http://mirror.bit.edu.cn/qtproject/\">http://mirror.bit.edu.cn/qtproject/</a></span></span></p></li><li><p><span><span style=\"color: rgb(68,68,68);\">中国互联网络信息中心:</span><span style=\"color: rgb(0,125,187);\"><a href=\"https://mirrors.cnnic.cn/qt/\">https://mirrors.cnnic.cn/qt/</a></span></span></p></li></ul><p><span style=\"color: rgb(34,34,34);\">下载windows系统安装文件“</span><br style=\"text-align: justify;\" /><span style=\"color: rgb(34,34,34);\">qt-opensource-windows-x86-*.exe ”。该文件比较大,约2.3GB,其中集成了32位和64位的安装包。对于Linux和Mac系统,可以分别下载相应的文件进行安装。</span></p><p><span style=\"color: rgb(34,34,34);\">以第一个中科大的镜像为例,进入网页后依次点击下图红框内的链接。</span></p><p><span style=\"color: rgb(34,34,34);\"><ac:image ac:height=\"250\"><ri:attachment ri:filename=\"Dingtalk_20230708150741.jpg\" /></ac:image></span></p><p>第二步: 下载安装包<br />选择QT—<span style=\"color: rgb(77,77,77);\">QT5.15.0版本开始,官方不再提供离线版安装包,除非你充钱买商业版。</span>,下载<a href=\"https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-windows-x86-5.14.2.exe\">qt-opensource-windows-x86-5.14.2.exe</a>即可。<br />注意:不要选择5.15及以上的版本,否则安装会很麻烦<ac:image ac:height=\"173\" ac:width=\"554\"><ri:attachment ri:filename=\"worddav093fa6a048a3925a3ee79bfb6dd619aa.png\" /></ac:image></p><p><span style=\"color: rgb(255,0,0);\"><strong>建议安装之前先断网,要不然会弹出注册页面!!!</strong></span><br class=\"atl-forced-newline\" /><span style=\"color: rgb(51,51,51);\">双击启动安装包之后,将会打开一个欢迎界面。在这里,直接点击"下一步"即可。</span><br /><ac:image ac:height=\"556\" ac:width=\"491\"><ri:attachment ri:filename=\"worddavffd612ef628a9d8f08951d0253c1f912.png\" /></ac:image> <br /><span style=\"color: rgb(51,51,51);\">接着,会提示你登陆 Qt </span><span style=\"color: rgb(77,77,77);\">账户。这个 Qt 账户对普通人来说没什么必要,所以直接点击下面的"Skip"跳过即可。</span><br /><ac:image ac:height=\"558\" ac:width=\"499\"><ri:attachment ri:filename=\"worddavfff5d0c2e5ae2c6c339dcd1d311d4276.png\" /></ac:image><br /><span style=\"color: rgb(51,51,51);\">随后,便会弹出真正的开始安装界面,点击"下一步"。</span><br /><ac:image ac:height=\"560\" ac:width=\"498\"><ri:attachment ri:filename=\"worddav8cda9455ee7dfcc7281e593047ba371a.png\" /></ac:image> <br /><span style=\"color: rgb(51,51,51);\">在安装文件夹的界面,建议大家不要将 Qt </span><span style=\"color: rgb(77,77,77);\">安装在系统盘 C 盘(比如我在此作了更改,将其安装到 D 盘。当然,你安装在 C 盘也是可以的),其他保持默认即可。继续点击"下一步"。</span><br /><ac:image ac:height=\"560\" ac:width=\"500\"><ri:attachment ri:filename=\"worddava78bf3d8d93bea6ed96cdf0b969e64a4.png\" /></ac:image><br /><span style=\"color: rgb(51,51,51);\">下面,就到了重点了。在选择组件界面,请务必要选对安装 Qt </span><span style=\"color: rgb(77,77,77);\">所需要的组件,否则你安装以后是无法正常运行的。</span><br /><span style=\"color: rgb(51,51,51);\">首先,点击各项前面的 > </span><span style=\"color: rgb(77,77,77);\">箭头展开子项的内容。</span><br /><ac:image ac:height=\"560\" ac:width=\"501\"><ri:attachment ri:filename=\"worddave8c9e0d51b1cdd3075f9a4d329adb16a.png\" /></ac:image><br />在 Qt5.9 一项中,如果你是使用 MinGW 进行编译,请务必选中 MinGW 模块。而如果你希望调用 VS 的编译器进行编译,则需要勾选对应的 VS 模块。当然,如果希望进行安卓开发,则安卓模块是少不了了。 <br class=\"atl-forced-newline\" />至于其余的一些模块,则可以根据自身需要勾选。这里着重介绍下 Qt WebEngine 和三个后面带TP的模块项。Qt WebEngine是谷歌开源的 Web 浏览器引擎模块,而带 TP 的模块则表示此模块目前是技术预览版。 <br class=\"atl-forced-newline\" />我的建议是,如果你是初学,这些则可以不选。千万不要以为柿子西瓜一箩筐什么都选上是最好的,这样一来是增大存储空间,二来多多少少会影响 Qt 运行时的速度,增加不必要的内存消耗。</p><p>① MinGW 5.3.0 32 bit 编译器模块。MinGW 是 Minimalist GNU for Windows 的缩写,MinGW是 Windows 平台上使用的 GNU 工具集导入库的集合。</p><p>② 用于 UWP 编译的模块。UWP 是 Windows 10 中 Universal Windows Platform 的简称,有不同编译器类型的 UWP。</p><p>③ 用于 windows 平台上的 MSVC 编译器模块,如 msvc2015 32-bit 和 msvc2015 64-bit 等。要安装 MSVC 编译器的模块,需要计算机上已经安装相应版本的 Visual Studio。</p><p>④ 用于 Android 平台的模块,如 Android x86 和 Android ARMv7。</p><p>⑤ Sources 模块是 Qt 的源程序。</p><p>⑥ Qt Charts 是二维图表模块,用于绘制柱状图、饼图、曲线图等常用二维图表。</p><p>⑦ Qt Data Visualization 是三维数据图表模块,用于数据的三维显示,如散点的三维空间分布、三维曲面等。</p><p>⑧ Qt Purchasing、Qt WebEngine、Qt Network Auth(TP)等其他模块,括号里的 TP 表示技术预览(Technology Preview)。</p><p>⑨ Qt Scritp(Deprecated)是脚本模块,括号里的“Deprecated”表示这是已经过时的模块。</p><p>“Tools”节点下面是一些工具软件,包括内容如下:</p><p>① Qt Creator 4.3.1 是用于 Qt 程序开发的 IDE。</p><p>② MinGW 5.3.0 是 MinGW 编译工具链。</p><p>③ Strawberry Perl 是一个 Perl 语言工具。</p><p><br class=\"atl-forced-newline\" /><ac:image ac:height=\"559\" ac:width=\"496\"><ri:attachment ri:filename=\"worddav3ac3ebb67a3f0d2099b02bb809c4f4dc.png\" /></ac:image><br /><ac:image ac:height=\"556\" ac:width=\"499\"><ri:attachment ri:filename=\"worddav59651ba0b317e25b27ad16efde0d23d4.png\" /></ac:image><br />下面,接着看工具项(Tools)的选择。 <br class=\"atl-forced-newline\" />第一项是CDB的调试器,如果你仅使用 MinGW进行编译,则此项可以不选。 <br class=\"atl-forced-newline\" />第二项虽然名字带 MinGW,但只是用于交叉编译的(交叉编译即在某一平台上编译用于其他平台的程序),如果用不到,也可以不选。 <br class=\"atl-forced-newline\" />至于第三项,那是用于 Perl 的。如果你电脑中本身没有安装 Perl,那是装不上的。 <br class=\"atl-forced-newline\" />选择完成后,继续点击"下一步"。<br /><ac:image ac:height=\"560\" ac:width=\"495\"><ri:attachment ri:filename=\"worddavacf0ca8e91c7721d28e2473311d97a99.png\" /></ac:image> <br /><span style=\"color: rgb(51,51,51);\">接着,在打开的页面中勾选"我已经阅读并同意条款"(原文是英文)。然后,继续一路点击"下一步",直到安装完成就可以了。</span><br /><ac:image ac:height=\"559\" ac:width=\"496\"><ri:attachment ri:filename=\"worddav1915ef213c77eb332925674735caaff4.png\" /></ac:image></p>","representation":"storage","_expandable":{"content":"/rest/api/content/58954500"}},"_expandable":{"editor":"","view":"","export_view":"","styled_view":"","anonymous_export_view":""}},"extensions":{"position":1},"_links":{"webui":"/pages/viewpage.action?pageId=58954500","edit":"/pages/resumedraft.action?draftId=58954500","tinyui":"/x/BJODAw","collection":"/rest/api/content","base":"https://wiki.suncaper.net","context":"","self":"https://wiki.suncaper.net/rest/api/content/58954500"},"_expandable":{"container":"/rest/api/space/2CT","metadata":"","operations":"","children":"/rest/api/content/58954500/child","restrictions":"/rest/api/content/58954500/restriction/byOperation","history":"/rest/api/content/58954500/history","ancestors":"","descendants":"/rest/api/content/58954500/descendant","space":"/rest/api/space/2CT"}} |