【发布时间】:2018-11-11 10:07:50
【问题描述】:
我已经在我的*.pro 项目文件中定义了这个宏:
# The application version
VERSION = 6.10.0
# Define the preprocessor macro to get the application version in our application.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
然后我像这样设置我的应用程序版本:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
/*
* Setting the Application version
*/
app.setApplicationVersion(APP_VERSION);
// ...
}
现在我想访问我的 QML 代码中的应用程序版本,该代码位于 共享库 中。我怎样才能做到这一点? :
ColumnLayout {
id: versionLayout
StyledLabel {
text: qsTr("Version")
font.weight: Font.Bold
}
RowLayout {
StyledLabel {
Layout.alignment: Qt.AlignCenter
text: APP_VERSION // How can I access my macro/version here?
// QApplication.applicationVersion() is NOT working!
}
}
}
【问题讨论】: