Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HowTo set Icon to Qt Application, created with Qt Visual Studio Add-in?

Tags:

ico

qt

qt4

Here is what I have:

  • Visual Studio 2008 (on 32-bit Windows XP)
  • Qt libraries 4.6.2 for Windows (VS 2008, 194 MB)
  • Visual Studio Add-in (44 MB)

After I installed all the software, I created simple Qt Application project, with Visual Studio: menu File | New | Project... and Qt4 Projects | Qt Application.

Build it, and here is the question: how to set application icon to my compiled exe file? I need to see specified ICO in explorer!


Old method with MyProject.pro not interested!!!

  1. Create a .ico file with both 16x16 and 32x32-pixel versions of the icon (you can do this in Visual Studio).

  2. Create a .rc file containing the following text:

    IDI_ICON1 ICON DISCARDABLE "myIcon.ico"

  3. Add the following to your .pro file

    RC_FILE = myFile.rc

  4. Run qmake.

Thanks.

like image 678
mosg Avatar asked Jun 01 '10 11:06

mosg


2 Answers

This is what worked for me [VS2010, Qt Add-in 1.1.8], for an existing project:

As in the docs at http://doc.qt.io/qt-4.8/appicon.html :

  • Add icon file (myappico.ico) to source dir

  • Create myapp.rc file with the line

    IDI_ICON1 ICON DISCARDABLE "myappico.ico"

[Of course, the file names are free to choose, as long as they are consistent]

  • Right-click project, choose Add | Existing item... and pick the RC file

  • Rebuild

like image 111
Marc Avatar answered Nov 15 '22 07:11

Marc


Totally, I have found the correct solution, here it is:

Preamble: You need Visual Studio Add-in already installed!

  1. Open Visual Studio (or Visual C++)

  2. Create new project from menu: File | New | Project... and select project type as Qt4 Projects and for example Qt Application from templates.

  3. When the first dialog window will be shown, just click Next > button twice.

  4. And finally in Generated Class tap the Add default application icon (Windows only) checkbox.

    alt text http://www.freeimagehosting.net/uploads/7f87801fb9.png

  5. To finish process, just press Finish.

Project will create a default icon, with name {your_project_name}.ico. Replace it and have fun!

like image 28
mosg Avatar answered Nov 15 '22 07:11

mosg