Best practice for setting Windows .exe properties with Qt Creator?
-
Is putting
VERSION = 0.0.0.1
QMAKE_TARGET_COMPANY = company
QMAKE_TARGET_PRODUCT = product
QMAKE_TARGET_DESCRIPTION = description
QMAKE_TARGET_COPYRIGHT = copyrightin the .pro file the best way to do it?
Also, I was trying to make the appname and version to show on my app title, but somehow I get an error.
I add these lines to the .pro file:
DEFINES += APP_NAME=\"Test Name Application\"
VERSION = 1.2.3
DEFINES += APP_VERSION=\"$$VERSION\"and this line to the main.cpp file:
w.setWindowTitle(QString(APP_NAME).replace("_"," ") + QString(" - ") + APP_VERSION);
But I get the following errors when compiling:
C2065: 'Test': identifier not declared
C2228: left of '.replace' must have class/struct/union -
Hi,
You're not escaping your quotes enough for your defines on Windows.
An alternative would be to use
QMAKE_SUBSTITUTES
and generate a header which will contain the info you want.Hope it helps.
-
I was talking about your
DEFINES
.I usually used an rc file and haven't yet used
QMAKE_TARGET_COMPANY
and its friends. -
Hi @racingame,
Couldn't you please provide the lines of codes you generally use for populating the properties fields for a Windows application?
Like @SGaist, I tend you use my own rc file (just allows you to do a whole lot more than qmake is aware of), but you can see plenty of real-world examples on GitHub via a code search like this one: https://github.com/search?l=QMake&q=QMAKE_TARGET_COMPANY&type=Code
As for:
DEFINES += APP_NAME=\"Test Name Application\" VERSION = 1.2.3 DEFINES += APP_VERSION=\"$$VERSION\"
The problem here is that the arguments are not being escaped correctly when passed to the compiler. For this, I suggest you use QMake's shell_quote function like:
DEFINES += APP_NAME=$$shell_quote(\"Test Name Application\") VERSION = 1.2.3 DEFINES += APP_VERSION=$$shell_quote(\"$$VERSION\")
Cheers.