set(VERSION "1.0.0.0")
# 將變數定義為前處理器宏
add_definitions(-DVERSION="${VERSION}")
程式碼中呼叫:
QString version = QCoreApplication::applicationVersion(); QString verInfo = " 軟體工具 - 版本:V" + QString(VERSION) + QString((version.right(1) != "0") ? " debug" : " release"); this->setWindowTitle(verInfo);