Setting the Qt Application Icon

QT 开发之一 : 应用程序ICON 应用程序的图标是应用程序很重要的一部分, 阅读详情

Setting the Application Icon

The application icon, typically displayed in the top-left corner of an application's top-level windows, is set by calling the QWidget::setWindowIcon() method on top-level widgets.

In order to change the icon of the executable application file itself, as it is presented on the desktop (i.e., prior to application execution), it is necessary to employ another, platform-dependent technique.

Setting the Application Icon on Windows

First, create an ICO format bitmap file that contains the icon image. This can be done with e.g. Microsoft Visual C++: Select File|New, then select the File tab in the dialog that appears, and choose Icon. (Note that you do not need to load your application into Visual C++; here we are only using the icon editor.)

Store the ICO file in your application's source code directory, for example, with the name myappico.ico. Then, create a text file called, say, myapp.rc in which you put a single line of text:

 IDI_ICON1               ICON    DISCARDABLE     "myappico.ico"

Finally, assuming you are using qmake to generate your makefiles, add this line to your myapp.pro file:

 RC_FILE = myapp.rc

Regenerate your makefile and your application. The .exe file will now be represented with your icon in Explorer.

If you do not use qmake, the necessary steps are: first, run the rc program on the .rc file, then link your application with the resulting .res file.

Setting the Application Icon on Mac OS X

The application icon, typically displayed in the application dock area, is set by calling QWidget::setWindowIcon() on a top-level widget. It is possible that the program could appear in the application dock area before the function call, in which case a default icon will appear during the bouncing animation.

To ensure that the correct icon appears, both when the application is being launched, and in the Finder, it is necessary to employ a platform-dependent technique.

Although many programs can create icon files (.icns), the recommended approach is to use the Icon Composer program supplied by Apple (in the Developer/Application folder). Icon Composer allows you to import several different sized icons (for use in different contexts) as well as the masks that go with them. Save the set of icons to a file in your project directory.

If you are using qmake to generate your makefiles, you only need to add a single line to your .pro project file. For example, if the name of your icon file is myapp.icns, and your project file is myapp.pro, add this line to myapp.pro:

 ICON = myapp.icns

This will ensure that qmake puts your icons in the proper place and creates an Info.plist entry for the icon.

If you do not use qmake, you must do the following manually:

  1. Create an Info.plist file for your application (using the PropertyListEditor, found in Developer/Applications).
  2. Associate your .icns record with the CFBundleIconFile record in the Info.plist file (again, using the PropertyListEditor).
  3. Copy the Info.plist file into your application bundle's Contents directory.
  4. Copy the .icns file into your application bundle's Contents/Resources directory.

Setting the Application Icon on Common Linux Desktops

In this section we briefly describe the issues involved in providing icons for applications for two common Linux desktop environments: KDE and GNOME. The core technology used to describe application icons is the same for both desktops, and may also apply to others, but there are details which are specific to each. The main source of information on the standards used by these Linux desktops is freedesktop.org. For information on other Linux desktops please refer to the documentation for the desktops you are interested in.

Often, users do not use executable files directly, but instead launch applications by clicking icons on the desktop. These icons are representations of "desktop entry files" that contain a description of the application that includes information about its icon. Both desktop environments are able to retrieve the information in these files, and they use it to generate shortcuts to applications on the desktop, in the start menu, and on the panel.

More information about desktop entry files can be found in the Desktop Entry Specification.

Although desktop entry files can usefully encapsulate the application's details, we still need to store the icons in the conventional location for each desktop environment. A number of locations for icons are given in the Icon Theme Specification.

Although the path used to locate icons depends on the desktop in use, and on its configuration, the directory structure beneath each of these should follow the same pattern: subdirectories are arranged by theme, icon size, and application type. Generally, application icons are added to the hicolor theme, so a square application icon 32 pixels in size would be stored in the hicolor/32x32/apps directory beneath the icon path.

K Desktop Environment (KDE)

Application icons can be installed for use by all users, or on a per-user basis. A user currently logged into their KDE desktop can discover these locations by using kde-config, for example, by typing the following in a terminal window:

 kde-config --path icon

Typically, the list of colon-separated paths printed to stdout includes the user-specific icon path and the system-wide path. Beneath these directories, it should be possible to locate and install icons according to the conventions described in the Icon Theme Specification.

If you are developing exclusively for KDE, you may wish to take advantage of the KDE build system to configure your application. This ensures that your icons are installed in the appropriate locations for KDE.

The KDE developer website is at http://developer.kde.org/.

GNOME

Application icons are stored within a standard system-wide directory containing architecture-independent files. This location can be determined by using gnome-config, for example by typing the following in a terminal window:

 gnome-config --datadir

The path printed on stdout refers to a location that should contain a directory called pixmaps; the directory structure within the pixmaps directory is described in the Icon Theme Specification.

If you are developing exclusively for GNOME, you may wish to use the standard set of GNU Build Tools, also described in the relevant section of the GTK+/Gnome Application Development book. This ensures that your icons are installed in the appropriate locations for GNOME.

The GNOME developer website is at http://developer.gnome.org/.

Setting the Application Icon on the Symbian platform

In order to set the application icon for Symbian platform applications, you need an SVG-T icon. For information on how to create SVG-T compliant icons, please refer to http://wiki.forum.nokia.com/index.php/How_to_create_application_icon(SVG)_in_S60_3rd_edition

Once the icon is available in the correct format and assuming you are using qmake to generate your makefiles, you only need to add a single line to your .pro project file. For example, if the name of your icon file is myapp.svg, and your project file is myapp.pro, add this line to myapp.pro:

 ICON = myapp.svg
QT Creator创建菜单,添加图标和背景图片 一. 首先创建一个 project. New->QT4 Gui Application. 创建完毕后,点击 XXX.ui ,开始添加菜单:双击左上角的 ”Type Here” 进行编辑,编辑完后回车(回车很重要),回车后就会出现下拉菜单,继续类似编辑。 Ok, 菜单编辑完成了,界面的 Action Editor 就会有你添加的内容 , 如下 . 二,之后会在资源管理窗口看见编辑的菜单 阅读详情

相关推荐

QT事件机制详解

分别从事件的类型、事件的产生、事件循环和传播、事件的处理这四个方面来详细理解QT的事件机制

qq_40867178的博客 4486

linux创建桌面图标,和开始菜单栏图标

###环境:Mint17,(其他类似的linux系统是一样的) 如果开始菜单有图标,创建桌面图标很简单,右键添加到桌面即可。 如果没有,就要动手写一个了,需要两个东西一个是图标样式的图片,一个是自己创建.desktop的配置文件。 1,图标按自己喜欢的找,或者找软件里自带的***.png ***.jpg。 位置根据下面配置文件里指定的位置放对应的位置 2.***.desktop配

yuanzhiyuan的博客 6607

从PyCharm+Qt Designer切换到Qt Creator:如何正确设置项目并一键生成槽函数?

本文详细介绍了从PyCharm+Qt Designer切换到Qt Creator的高效GUI开发方法,重点解析了正确设置项目并一键生成槽函数的步骤。通过对比两种开发模式的核心差异,指导开发者如何创建Qt Widgets Application项目、配置.pro文件以及使用Qt Creator的设计模式,显著提升开发效率。

weixin_30265103的博客 409

Qt Application Icon Setting(Qt在不同平台下的图标设置)

英文原文: Setting the Application Icon The application icon, typically displayed in the top-leftcorner of an application's top-level windows, is set by calling theQWindow::setWindowIcon() method. In

止于至善 4801

使用Qt开发过程中遇到的几个小问题

一、打包Qt应用程序 一、对于Qt Quick Application发布方式 1、把relaese下的.exe和数据库复制到一个文件夹gu中 2、从开始菜单打开 Qt 命令行,进入D:\gu\文件夹: cd D:\gu 或者是 cd /d d:\gu 3、然后使用 windeployqt 工具命令找到对应的(qml)路径: windeployqt gu.exe --qmld...

Guo_Li_duo的博客 689

常见的十大量化投资策略(附源码)

量化投资策略是利用量化的方法,进行金融市场的分析、判断和交易的策略、算法的总称。著名的量化投资策略有以下10种(注:策略源码模板不能直接用于实盘交易,仅供探讨交流) 01、海龟交易策略 海龟交易策略是一套非常完整的趋势跟随型的自动化交易策略。这个复杂的策略在入场条件、仓位控制、资金管理、止损止盈等各个环节,都进行了详细的设计,这基本上可以作为复杂交易策略设计和开发的模板。 海龟交易策略源码:https://www.myquant.cn/docs/python_strategyies/110 0.

小壁虎的春天 2万+

Icon Naming Specification

Rodney Dawes <dobey.pwns@gmail.com> Version 0.8.90 Table of Contents OverviewContextIcon Naming GuidelinesStandard Icon NamesA. Change History ...

diaoyutai9210的博客 471

电影台词预测类型:NLP小样本多标签分类实战

电影类型预测本质上是短文本语义建模问题,核心在于从高度碎片化、低语义密度的台词(平均仅12.7词)中挖掘隐含的类型学编码规则。其技术难点在于:需应对省略主语、倒装、拟声词等非规范表达;处理Drama与Comedy等类型强共现的多标签耦合;并克服领域迁移障碍——维基文本预训练模型在台词上性能骤降0.11。解决方案聚焦RoBERTa微调、类型感知注意力机制与标签平滑策略,兼顾小样本鲁棒性与业务可解释性,广泛适用于影视元数据标注、智能推荐系统及NLP教学实践。

weixin_33309048的博客 287

XDG规范有哪些

XDG规范有哪些

OS Developer的博客 1370

基于航位推算与多传感器融合的高精度避障小车设计

航位推算(Dead Reckoning)是一种在无外部定位信号下通过里程计与惯性测量单元(IMU)持续积分估计位姿的基础导航方法,其核心在于运动学建模、误差累积抑制与多源数据融合。该技术具备低依赖、高实时、强确定性等工程优势,广泛应用于服务机器人、AGV、竞赛无人平台等受限环境下的自主导航系统。结合编码器高分辨率测距与九轴IMU姿态解算,可显著抑制纯里程计漂移,提升短时定位精度至厘米级。本文以全国大学生电子设计竞赛K题为背景,深入实现了一种面向确定性场地的离线建图+航位推算双模协同架构,重点解决嵌入式资源约

weixin_36328210的博客 81

MATLAB控制信号发生器(USB-GPIB-HS)GPIB仪器控制教程(含matlab代码)

自动化测试时需要自动产生信号,通过matlab控制信号发生器的频率与功率,以实现自动化信号生成输出

qq_43686057的博客 1606

Linux Desktop Entry 文件深入解析

级别: 初级 龚 奕平 (gongyp@cn.ibm.com), IBM 中国软件开发中心 WPLC 部,软件工程师 2007 年 7 月 12 日 Desktop Entry 文件是 Linux 桌面系统中用于描述程序启动配置信息的文件。Desktop Entry 文件实现了类似于 Windows 操作系统中快捷方式的功能。本文详细介绍了 Linux Desktop Entry 文件的定义...

weixin_33980459的博客 157

论文阅读——Bayesian Knowledge Fusion(贝叶斯知识融合)

该篇论文解决了不确定环境中的信息融合问题。想象一下,有多位专家针对同一情况构建概率模型,我们希望汇总他们提供的信息。直接合并每个信息可能会遇到几个问题。例如,专家们可能不同意某个事件发生的概率,或者他们可能不同意两个事件之间因果关系的方向(例如,一个人认为 A 导致 B,而另一个人认为 B 导致 A)。他们甚至可能不同意概率网络中一组变量之间的整个依赖结构。

qq_64164071的博客 1496

Setting the Application Icon (QT设置软件图标)

在写好一个软件后,最后的工作是为该软件设置一个图标,用于显示该软件与其它软件区别和表明功能。 认真阅读下面的内容,就可以做到图标的设置 ...

pangyinglong的博客 474

Flutter项目在M1/M2 Mac上跑iOS模拟器报错?手把手教你搞定‘arm64架构不兼容’问题

本文详细解析了Flutter项目在M1/M2 Mac上运行iOS模拟器时遇到的‘arm64架构不兼容’问题,提供了多种解决方案,包括排除模拟器的arm64架构、强制使用x86_64架构以及修改插件Podspec文件。帮助开发者快速解决架构兼容性问题,提升开发效率。

weixin_33713707的博客 335

【数据集2】CPC Global Unified Temperature/Precipitation数据简介及处理

简介CPC 温度及降雨 数据

WW、forever的博客 3105

Qt Setting Application Icon

Qt4 设置应用程序图标 将一个ico图标放在资源文件夹下; 然后建立txt,输入 IDI_ICON1 DISCARABLE “myico.ico”; 保存文件,将其后缀改为.rc; 然后,在项目目录pro的文件里加入 RC_FILE += myico.rc; 直接运行程序,这样MainWindows窗口图标的左上角的图标和debug里面的可执行程序的图标就变了。我的天啊,这是要累死人的节奏....

weixin_30648963的博客 190

ubuntu20.04屏幕亮度无法调节(亮度条调节无效)的简单靠谱解决方案及踩坑历程

0 前言   网上关于ubuntu系统亮度无法调节的问题的解决方法有很多,但是绝大部分并没有什么用(这也是我自己的亲身体会),或者并不靠谱。在遍尝各路方法过后,我终于解决了这一棘手的问题(毕竟最大亮度真的非常刺眼,无法长时间直视),在此记录一下踩坑历程以及最后的解决方案。 1 Naive方法   由于使用需要,最近在电脑原有的win10基础上安装了ubuntu双系统。我安装的是当前新版的ubuntu20.04.2.0,靠谱的安装教程可以参考这里。   之前师兄说双ssd安装双系统会有系统启动引导的问题出现,

zeeq的博客 4万+

How to set the QT Application icon in the windows.

在Qt助手(assistant.exe)搜索关键字"Setting the Application Icon"就可以看到在各种平台设置Qt程序图标的方法。 首先准备个ICO图标。例如:myappico.ico 用任何文本编辑器新建个文件 里面就写一行: [cpp] view plaincopy IDI_ICON1

lin28690的专栏 438

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

How to embed an icon in a Qt application

This approach holds for any type of an external file that needs to be embedded in an executable, such as an image (icon), a text file containing help etc. The embedding is accomplished by creating a Q

Jared_LAU的专栏 735

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

老牛知点所以然-QT桌面应用添加图标(Application ICON)

如何替换QT桌面应用的图标,这么简单的一个需求,却让人折腾了半天. 本人使用的是Linux版本Qt Creator4.12.4, Qt 5.14.2,版本有点老了,但是这块的内容应该不影响. 网上的博文,一没有指明版本,二是说的太粗略,让人一头雾水,我跟着做,竟然没有看到预期的效果,光火. 文章目录第一种替换方式:第二种替换方式第三种方式-代码 首先,更正其他博文一点:替换桌面应用Icon,并不是要求图片格式一定是ico格式的;如果你是代码的方式,替换默认图标,那必须是ico格式的图片;但是如果从编辑器设置

Fozei的博客 1074

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Qt应用程序图标的添加

Qt应用程序图标的添加前言桌面版程序Qt4版本方法Qt5版本方法Qt on Android程序 前言 闲来无事,在此记录Qt应用程序图标的添加方法~~ 桌面版程序 Qt4版本方法 1、找一张ico格式图片,命名为remoteClient.ico 2、在工程文件目录下新建文本文件,内容为IDI_ICON1 ICON DISCARDABLE “remoteClient.ico”,然后将文本文件重新命名...

大千世界 519

关于Qt Creator设置Application ICON图标显示不出来的问题

1、问题: 最近在学习,Qt Creator快速入门真本书时,按照书上的提示,运行Hello World工程时,没有正常先生ApplicationIcon图标。 按照书上做了以下两个工作。a.拷贝了myicon.ico文件到helloworld目录(myicon.ico文件可以去实列代码的hellowordl里面拷贝过来,或者用网上在线转换工具把jpg转换成ico文件)b.在.pro文...

sinat_41928334的博客 5440

【框架-QT】修改程序图标

准备图标 Application.ico 添加资源文件icon.rc IDI_ICON1 ICON DISCARDABLE "Application.ico" 添加对资源文件的引用 *.pro #------------------------------------------------- # # Project created by QtCreator 2016-02-25

少莫千华 409

qt android 锁定屏幕,QT5 for android 实现横屏锁定

首先要找到AndroidManifest.xml 这个文件,如果没找到则需要手动新建, 这个默认是不会创建的, 我们设置qt for android app图标时,也需要这个文件。手动创建自动生成这个AndroidManifest.xml 这个文件, 我所说的是QT5的版本, 至于其它版本,暂时也没有深究过。手动创建的流程为: 顺便提一下更改app图标 如上图所示,当我们创建了AndroidMan...

weixin_30682043的博客 514

linux qt应用程序全屏,Linux/QT 如何设置Qt应用程序图标

在Qt助手(assistant.exe)搜索关键字”Setting the ApplicationIcon”就可以看到在各种平台设置Qt程序图标的方法。Setting the Application Icon on WindowsFirst, create an ICO format bitmap file that contains the iconimage. This can be done...

weixin_30496435的博客 392
上一篇: Zigbee和Wi-Fi的干扰和共存
下一篇: PC与单片机USB(D12)数据通讯过程描述
獠
獠
博客等级 码龄16年 43粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值