Jump to content

Qt for HarmonyOS/qtohosextras doc/Share Data Example: Difference between revisions

From Qt Wiki
Add example documentation from qdoc output (QTFOROH-2307)
 
Fix example page conversion (QTFOROH-2307)
Line 1: Line 1:
< [[Qt_for_HarmonyOS/qtohosextras_doc|Qt for HarmonyOS / qtohosextras doc]]
< [[Qt_for_HarmonyOS/qtohosextras_doc|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


[[Category:Qt for HarmonyOS]]
[[Category:Qt for HarmonyOS]]

Revision as of 09:27, 16 September 2026

< 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