我在linux中開發了一個GUI應用程序。 當前,應用程序的版本信息顯示在GUI內。
現在,我的客戶想他應該能夠檢查通過輸入應用程序的版本,下面的命令:如何爲linux應用程序添加版本信息
[shell]: appName --version
我所做如下:
int main(int argc, char *argv[])
{
/* Initialize Qt Application */
QApplication simulatorGUI(argc, argv);
QStringList argList = simulatorGUI.arguments();
if((argList.count() == 2) && (argList[1].toStdString() == "--version"))
{
cout << "App Simulator V2.3" << endl;
}
simulatorGUI.setStyle(new QCleanlooksStyle);
appSimulator simulatorInstance;
simulatorInstance.show();
return simulatorGUI.exec();
}
使用此代碼我能夠檢查我的應用程序的版本信息爲:
[shell]: ./appSimulator --version
App Simulator V2.3
並運行該應用程序,我使用以下命令:
[shell]: ./appSimulator
我的疑問是:
1.這是執行的正確方法?
2.是否有更好的實現方法?我能做到這樣的:
[shell]: appSimulator --version
,而不是
[shell]: ./appSimulator --version
?
謝謝。
不要忘記實施'appsSiulator --help'程序參數。 – 2013-04-24 06:03:39