Jump to content

Qt for HarmonyOS/qtohosextras doc/Share Data Example

From Qt Wiki
Revision as of 09:27, 16 September 2026 by Shawn Luo (talk | contribs) (Fix example page conversion (QTFOROH-2307))

< Qt for HarmonyOS / qtohosextras doc

Share Data Example

Demonstrates sharing text, file and URL records with other applications through OHOS Share Kit.


The window builds a list of shared records with ShareKit::createContentRecord(), ShareKit::createFileRecord() and ShareKit::createUrlRecord(), optionally decorated with title, label, description, extra data and a thumbnail. Controller options created with ShareKit::createControllerOptions() allow selecting single-selection mode, the default preview mode and the panel anchor. Share Records calls QOhosAbilityContext::shareDataWithShareKit() on the default instance and logs the returned request identifier; the QOhosAbilityContext::shareKitPanelClosed() and shareKitCompleted() signals are logged as they arrive, the latter delivering the target ability name through ShareKit::QOhosShareOperationResult.

Note: shareKitCompleted() can be emitted multiple times for one request, as the user can select several target applications; correlate signals with the request identifier returned by shareDataWithShareKit().


Images:

  • abilitycontext/sharedata/qt_logo.png