mainwindow_showcase 教学示例:补 Designer 双版本表单(mainwindow2)+ 表单维护
- 新增 mainwindow2.{h,cpp,ui}:用 Qt Designer 生成的第二套 QMainWindow 表单
(File/Edit/Help 菜单 + actionOpen/actionAbout_Me),供课堂对比「代码搭界面」
与「Designer 拖界面」两条路线。
- 新增子目录 CMakeLists.txt:供单独打开该示例构建(顶层 add_subdirectory 不递归,
与 lineedit_eye_toggle / mandelbrot_renderer 同模式)。
- mainwindow.ui / mainwindow.qrc:经 Designer 重新保存后的表单与资源清单维护
(iconset 去掉 resource= 显式引用、属性顺序由 Designer 重排)。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,10 +14,9 @@
|
||||
<string>QMainWindow 教学综合示例</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="mainwindow.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icons/app.png</normaloff>:/icons/app.png</iconset>
|
||||
</property>
|
||||
<!-- 5.5 中心部件:QTextEdit(编辑器主体) -->
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<property name="spacing">
|
||||
@@ -46,14 +45,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<!-- 5.1 菜单栏:文件 / 视图 / 帮助 -->
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@@ -95,9 +93,7 @@
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<!-- 5.3 状态栏(.ui 占位,永久标签在 .cpp 用 addPermanentWidget 添加) -->
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<!-- 5.2 工具栏:复用同一批 QAction(QAction 是菜单项与工具按钮的公共抽象) -->
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>主工具栏</string>
|
||||
@@ -113,7 +109,6 @@
|
||||
<addaction name="actionToggleDockFloating"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<!-- 5.4 铆接部件(浮动窗口):可拖出浮动、停靠到边缘 -->
|
||||
<widget class="QDockWidget" name="dockWidget">
|
||||
<property name="windowTitle">
|
||||
<string>浮动窗口</string>
|
||||
@@ -138,36 +133,35 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<!-- 5.1 QAction:菜单项与工具按钮的公共抽象。图标取自 5.6 资源文件 -->
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset resource="mainwindow.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icons/new.png</normaloff>:/icons/new.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新建</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>清空编辑区(5.5 中心部件)</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset resource="mainwindow.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icons/quit.png</normaloff>:/icons/quit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>退出</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>退出程序</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToggleToolBar">
|
||||
<property name="checkable">
|
||||
@@ -213,7 +207,7 @@
|
||||
</action>
|
||||
<action name="actionToggleDockFloating">
|
||||
<property name="icon">
|
||||
<iconset resource="mainwindow.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icons/dock.png</normaloff>:/icons/dock.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -281,7 +275,7 @@
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset resource="mainwindow.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icons/about.png</normaloff>:/icons/about.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -292,8 +286,6 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="mainwindow.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user