diff --git a/Software/Development/Environment/Qt/Qt_使用技巧.md b/Software/Development/Environment/Qt/Qt_使用技巧.md index d32dcf6..c7d782a 100644 --- a/Software/Development/Environment/Qt/Qt_使用技巧.md +++ b/Software/Development/Environment/Qt/Qt_使用技巧.md @@ -18,6 +18,42 @@ export QT_DEBUG_PLUGINS=1 可在直行程序时打印 PLUGINS 信息,以确认某些插件是否被正确加载。 +## 添加图标 + +### 制作图标 + +先安装 ImageMagic 工具,并将其添加到系统 PATH 下方便使用。 + +使用以下命令将多个不同尺寸的图片打包成一个 ICO 文件。 + +```sh +magick.exe convert icon-16.png icon-32.png icon-256.png myappico.ico +``` + +### 添加图标到应用 + +在 Qt .pro 文件中添加以下内容,以便将图标编译到 Qt 程序中: + +```sh +RC_ICONS = myappico.ico +``` + +However, if you already have an .rc file, for example, with the name myapp.rc, which you want to reuse, the following two steps will be required. First, put a single line of text to the myapp.rc file: + +```sh +IDI_ICON1 ICON "myappico.ico" +``` + +Then, add this line to your myapp.pro file: + +```sh +RC_FILE = myapp.rc +``` + +If you do not use qmake, the necessary steps are: first, create an .rc file and run the rc or windres program on the .rc file, then link your application with the resulting .res file. + +更详细内容见《[Setting the Application Icon](https://doc.qt.io/qt-5/appicon.html)》。 + ## Windows 下程序打包 可通过