has been very tangled to the QT application to add icon problem, on-line received once, but feel not complete, is now the implementation of their own process to record, in order to view later:
Learn about the QT assistant in the online example:
Setting the application Icon
The application icon, typically displayed in the Top-left corner of a application ' s top-level windows, is set by calling Theqwidget::setwindowicon () method on top-level widgets.
In order to change the icon of the executable application file itself, as it was presented on the desktop (i.e., prior to a Pplication execution), it is necessary to employ another, platform-dependent technique.
Setting the application Icon on Windows
First, create an ICO format bitmap file contains the icon image. This can is done with e.g. Microsoft Visual C + +: Selectfile| New, then select the File tab in the dialog that appears, and choose Icon. (Note that you don't need to load your application into Visual C + +; Here we is 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 is using qmake to generate your makefiles, add the line to your Myapp.pro file:
Rc_file = myapp.rc
Regenerate your makefile and your application. The. exe file is now being represented with your icon in Explorer.
If you don't use qmake, the necessary steps Are:first, run the RC program on the . rc file, th En link your application with the resulting . Res file.
The method can be divided into two types from the above:
1. Use the Software method to set the default icon for the program window, but it cannot change the icon of the application file. exe.
2. Use the Qmake to generate makefile, such as QT+ECLIPSE,QT creator through the "If you don't use qmake" before the method can be resolved
3. Using qt+vs2010 is not the case with qmake, you need to execute the "If you don't use qmake ..." method, first add the. rc file to the project, then compile the. rc file, and finally reconnect to change the icon.
Implementation process:
1. Set the default icon for all Windows when the application runs.
[CPP]View Plaincopy
- Qapplication A (argc, argv);
- Get executable program Path
[CPP]View Plaincopy
- QString dir = Qapplication::applicationdirpath ();
- To set the executable path to the current working path
- Qdir::setcurrent (dir);
- Qapplication::addlibrarypath ("./plugins");
[CPP]View Plaincopy
- Qapplication::addlibrarypath ("./images");
- A.setwindowicon (Qicon ("./images/myappico.ico"));
2. Generate the Makefile implementation process via Qmake:
A. Find a picture. ico, name changed to Myappico.ico;
B. Create a new text document, add internal idi_icon1 ICON discardable "Myappico.ico", and rename the file to myapp.rc;
C. Add rc_file = myapp.rc at the end of the Myapp.pro file, and after rebuilding, the modification succeeds.
3. Do not qmake generate makefile implementation process:
As in the previous two steps, the last step is to load the. rc file into the project, right-click the project-add-existing file, add right-click. rc file compile, rebuild the executable and modify it successfully
"Go" Set QT application icon and application name