Qt. Automatically adding version for application

﹥>﹥吖頭↗ 提交于 2019-11-29 13:19:04

问题


In a .pro file, I can set version of application such:

VERSION = <some version>

Is there a way of doing this automatically (e.g. getting the value from Mercurial)?


回答1:


If you can get the version from a shell command, you can assign it to the variable with the $$system qmake function.

So, for mercurial, you could try:

# if the version tag is <major version>.<minor version> 
VERSION = $$system(hg parents --template '{latesttag}.{latesttagdistance}')
# or if you fill all 3 positions manually: <major>.<minor>.<patchset>
VERSION = $$system(hg parents --template '{latesttag}')

Or if you are using the local revision number as the version:

VERSION = $$system(hg parents --template '{rev}')

which will only print that number without the uncommitted change indicator ('+').



来源:https://stackoverflow.com/questions/10550071/qt-automatically-adding-version-for-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!