Your problem is probably that you are including myicon.rc
as a regular file, and it is listed as a source file. It should not be listed there nor under headers, because it isn't going through the normal compiler. You do need to list it as RC_FILE = myapp.rc
.
http://doc.qt.io/qt-5/qmake-variable-reference.html#rc-file
Note that ICON
in .pro is only used on mac.
http://doc.qt.io/qt-5/qmake-variable-reference.html#icon
I've included sample code for how I typically handle my rc
file, a version file, and how it gets used in main.cpp
and in the .pro
file.
This should work in Qt Creator and Visual Studio.
Here are the files I use when I am doing versioning and icons in windows:
myapp.rc
// http://stackoverflow.com/questions/2784697/setting-application-info-in-qt
#include <windows.h>
#include "version.h"
// if you needed to maintain two different icons for your app, you could
// switch here using a #ifdef and #else
#define MYICON "my_icon.ico"
IDI_ICON1 ICON DISCARDABLE MYICON
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
version.h
#ifndef VERSION_H
#define VERSION_H
#define VER_FILEVERSION 0,1,0,0
#define VER_FILEVERSION_STR "0.1.0.0\0"
#define VER_PRODUCTVERSION 15,07,01,50
#define VER_PRODUCTVERSION_STR "15.07.01.50"
#define VER_COMPANYNAME_STR "MySoft"
#define VER_FILEDESCRIPTION_STR "Star Runner"
#define VER_INTERNALNAME_STR "Star Runner"
#define VER_LEGALCOPYRIGHT_STR "Copyright © MySoft"
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved"
#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR
#define VER_ORIGINALFILENAME_STR "star_runner.exe"
#define VER_PRODUCTNAME_STR "Star Runner"
#define VER_COMPANYDOMAIN_STR "mysoft.com"
#endif // VERSION_H
main.cpp
#include <QApplication>
#include "version.h"
#include <QSettings>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName(VER_PRODUCTNAME_STR);
a.setOrganizationName(VER_COMPANYNAME_STR);
a.setOrganizationDomain(VER_COMPANYDOMAIN_STR);
a.setApplicationDisplayName(VER_PRODUCTNAME_STR);
QSettings::setDefaultFormat(QSettings::IniFormat);
// Create the widget or main window here
return a.exec();
}
star_runner.pro
# all sorts of other things like SOURCES and HEADERS and FORMS, etc.
# ...
win32 {
# DEFINES -= UNICODE
RC_FILE += myapp.rc
}
macx {
ICON = my_icon.icns
}
OTHER_FILES += \
my_icon.ico \
my_icon.icns \
myapp.rc
And lastly when creating icons, I usually use Gimp, making them at least 256x256 and then exporting them at different sizes using Phoca Save Icons. Other times I'll just make an png and then use something from here.
Hope that helps.