PDA

View Full Version : Applications Properties and Icon



KaptainKarl
30th July 2013, 20:55
Build Environment: Qt 5.0.2, Qt Creator 2.7.0, MinGW 4.7, Windows 7 32-bit.

I'm trying to get both Application properties and Application ICON set.
If I create a file called logo.rc that contains:

IDI_ICON1 ICON DISCARDABLE "images/Application.ico

and add the following line to my .pro file:

RC_FILE=logo.rc

Then the logo gets set. But when I include these lines in the .pro:

QMAKE_TARGET_COMPANY = "MyCo Inc."
QMAKE_TARGET_PRODUCT = "myPRODUCT"
QMAKE_TARGET_DESCRIPTION = "myPRODUCT rules."
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013 MyCo, Inc"

The property values are NOT set.

If I remove the RC_FILE setting from the project, then the property values are set and a file named "<project>_resource.rc" is created in the project directory. Then the property values are set.

It seems I'm allowed only one .rc file per project. Is there a way to set both the Application ICON and the Application Properties or can I only set one or the other?

Karl

ChrisW67
30th July 2013, 21:43
If you want to set the details that Windows displays in Windows Explorer then that all goes in the Windows resource file VERSIONINFO block.
http://stackoverflow.com/questions/2784697/setting-application-info-in-qt

I have no idea where this QMAKE_TARGET_* variables idea came from. They are not documented anywhere I have seen.

KaptainKarl
30th July 2013, 22:01
Actually, I found them at the bottom of the very StackOverflow post you suggested. I've never seen them documented either, but they do work. They just seem to tell qmake to create the .rc file described at the top of that post. Nice and convenient for a programmer used to doing things in UNIX and not worrying about such features. The problem is the .rc file is stomped on every time qmake runs.

I was hoping someone knew of another undocumented variable that might add the ICON to the same .rc file or some other trick that might let me do both the ICON and still use the magic variables.

The full code I stole from that StackOverflow post looks like this:

TARGET = myAPP
VERSION = 1.0.0.3

QMAKE_TARGET_COMPANY = "MyCo Inc."
QMAKE_TARGET_PRODUCT = "myPRODUCT"
QMAKE_TARGET_DESCRIPTION = "myPRODUCT rules."
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013 MyCo, Inc"

DEFINES += \
APP_VERSION=\"\\\"$$VERSION\\\"\" \
APP_COMPANY=\"\\\"$$QMAKE_TARGET_COMPANY\\\"\" \
APP_PRODUCT=\"\\\"$$QMAKE_TARGET_PRODUCT\\\"\" \
APP_DESCRIPTION=\"\\\"$$QMAKE_TARGET_DESCRIPTION\\\"\" \
APP_COPYRIGHT=\"\\\"$$QMAKE_TARGET_COPYRIGHT\\\"\" \
APP_NAME=\\\"$$TARGET\\\"

That lets me do all kinds of fun things with the values in the application. I'll submit a case to Digia and see if they have any suggestions.

Karl

rglennie
24th August 2017, 16:23
If you add this to the .pro file:

RC_ICONS = "images/Application.ico"

and remove the RC_FILE altogether, then both properties and icon should work.