Jump to content

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

From Qt Wiki
Add example documentation from qdoc output (QTFOROH-2307)
 
Fix example page conversion (QTFOROH-2307)
Line 11: Line 11:
'''Note: '''Both the launch want and subsequent wants have to be handled; a null result from tryGetSharedRecordsFromShareKit() means the want carries no shared data.
'''Note: '''Both the launch want and subsequent wants have to be handled; a null result from tryGetSharedRecordsFromShareKit() means the want carries no shared data.


Files:
* [[Qt_for_HarmonyOS/qtohosextras_doc/Share_Data_Receiver_Example|abilitycontext/sharedatareceiver/main.cpp]]
* [[Qt_for_HarmonyOS/qtohosextras_doc/Share_Data_Receiver_Example|abilitycontext/sharedatareceiver/sharedatareceiver.pro]]
* [[Qt_for_HarmonyOS/qtohosextras_doc/Share_Data_Receiver_Example|abilitycontext/sharedatareceiver/sharedatareceiver.pro]]


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

Revision as of 09:27, 16 September 2026

< Qt for HarmonyOS / qtohosextras doc

Share Data Receiver Example

Demonstrates receiving Share Kit records delivered to the application through a want.


The window is a log view. At startup the example reads QOhosAppContext::getAppLaunchWantInfo() and calls QOhosWantInfo::tryGetSharedRecordsFromShareKit(), printing the MIME type, content and file path of every record, or a note that no shared data arrived. The same handling is connected to QOhosAbilityContext::newWantInfoReceived() so shares that arrive while the application is already running are logged as well.

Note: Both the launch want and subsequent wants have to be handled; a null result from tryGetSharedRecordsFromShareKit() means the want carries no shared data.