Jump to content

Qt for HarmonyOS/qtohosextras doc/Start Ability For Result Example

From Qt Wiki
Revision as of 09:12, 16 September 2026 by Shawn Luo (talk | contribs) (Add example documentation from qdoc output (QTFOROH-2307))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< Qt for HarmonyOS / qtohosextras doc

Start Ability For Result Example

Demonstrates starting another UIAbility and receiving its result asynchronously.


Three buttons start a target ability with QOhosAbilityContext::startAbilityForResult(): with a want only, with a want and start options built via QtOhosExtras::createStartOptions(), and with an intentionally empty want to exercise the error path. A dialog collects the target bundle and ability names. Every call returns a request identifier which is logged; results arrive through the startAbilityForResultResponseReceived() signal with the result code and an optional returned want, and failures through startAbilityForResultErrorResponseReceived().

Note: Requests are asynchronous and several can be outstanding, so results must be correlated with the returned request identifier; there is no blocking variant of startAbilityForResult(). At minimum the bundle name and the ability name must be set on the want.

Files: