Qt4 how to set the application icon-Windows Platform

Source: Internet
Author: User

By searching for Qt assistant, we found the following descriptions:

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. rcregenerate 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.

The practice is clear:

Step 1: Prepare an ico icon.

For example, MyApp. ICO creates a file using any text editor.

Write a line in it:
Idi_icon1 icon discardable "MyApp. ICO"
 

Step 2: Save and change the name to MyApp. RC and place it and your icon MyApp. ICO in the directory of your QT project.

Step 3: Open your QT project file (such as MyApp. Pro) in a text editor and add a new line at the end of the file:
Rc_file = MyApp. RC

Step 4: Add the following code to the program:

// The app is the only qapplication object in the program.

App. setdomainwicon (qicon ("MyApp. ICO "));

NOTE: If your MyApp. RC and MyApp. ICO are not in your QT project directory, specify the path of the icon file in the code in the last sentence.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/qter_wd007/archive/2010/10/31/5978188.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.