Qt for HarmonyOS/qtohosextras doc/App Bundle Info Example: Difference between revisions
Fix example page conversion (QTFOROH-2307) |
Add code snippets to example pages (QTFOROH-2307) |
||
| Line 8: | Line 8: | ||
The example shows a single label with the application's version code. The value is obtained at startup with QtOhosExtras::QOhosAppContext::instance(), followed by QOhosAppContext::getBundleInfo() and QOhosBundleInfo::versionCode(). The call is synchronous, so no signal handling is required. | The example shows a single label with the application's version code. The value is obtained at startup with QtOhosExtras::QOhosAppContext::instance(), followed by QOhosAppContext::getBundleInfo() and QOhosBundleInfo::versionCode(). The call is synchronous, so no signal handling is required. | ||
<syntaxhighlight lang="cpp"> | |||
auto *appContext = QtOhosExtras::QOhosAppContext::instance(); | |||
auto bundleInfo = appContext->getBundleInfo(); | |||
QLabel label(QString("Application Version Code: %1").arg(bundleInfo->versionCode())); | |||
</syntaxhighlight> | |||
* [[Qt_for_HarmonyOS/qtohosextras_doc/App_Bundle_Info_Example|appbundleinfo/main.cpp]] | * [[Qt_for_HarmonyOS/qtohosextras_doc/App_Bundle_Info_Example|appbundleinfo/main.cpp]] | ||
[[Category:Qt for HarmonyOS]] | [[Category:Qt for HarmonyOS]] | ||
Revision as of 10:09, 16 September 2026
< Qt for HarmonyOS / qtohosextras doc
App Bundle Info Example
Demonstrates how to read the application's bundle information at runtime.
The example shows a single label with the application's version code. The value is obtained at startup with QtOhosExtras::QOhosAppContext::instance(), followed by QOhosAppContext::getBundleInfo() and QOhosBundleInfo::versionCode(). The call is synchronous, so no signal handling is required.
auto *appContext = QtOhosExtras::QOhosAppContext::instance();
auto bundleInfo = appContext->getBundleInfo();
QLabel label(QString("Application Version Code: %1").arg(bundleInfo->versionCode()));