Jump to content

Qt for HarmonyOS/qtohosextras doc/QOhosWantInfo Class: Difference between revisions

From Qt Wiki
Created page with "< Qt for HarmonyOS / qtohosextras doc = QOhosWantInfo Class = The QOhosWantInfo class is to represent Ohos want type. More... {| class="wikitable" |- ! Header: | #include <QOhosWantInfo> |- ! qmake: | QT += ohosextras |- ! Since: | Qt 5.12.12 |} * List of all members, including inherited members == Public Types == {| class="wikitable" style="width:100%" |- | class || '''ContactInfo_Cl..."
 
Drop manual breadcrumb, MediaWiki renders it automatically (QTFOROH-2307)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
< [[Qt_for_HarmonyOS/qtohosextras_doc|Qt for HarmonyOS / qtohosextras doc]]
= QOhosWantInfo Class =


= QOhosWantInfo Class =
class [[Qt_for_HarmonyOS/qtohosextras_doc/Qt_Ohos_Extras_C++_Classes|QtOhosExtras]]::QOhosWantInfo


The QOhosWantInfo class is to represent Ohos want type. More...
The QOhosWantInfo class is to represent Ohos want type. [[#details|More...]]


{| class="wikitable"
{| class="wikitable"
|-
|-
! Header:
| Header:
| #include <QOhosWantInfo>
| #include <QOhosWantInfo>
|-
|-
! qmake:
| qmake:
| QT += ohosextras
| QT += ohosextras
|-
|-
! Since:
| Since:
| Qt 5.12.12
| Qt 5.12.12
|}
|}


* [[List_of_All_Members_for_QOhosWantInfo|List of all members, including inherited members]]
This class was introduced in Qt 5.12.12.
 
* [[Qt_for_HarmonyOS/qtohosextras_doc/List_of_All_Members_for_QOhosWantInfo|List of all members, including inherited members]]


== Public Types ==
== Public Types ==


{| class="wikitable" style="width:100%"
{| class="wikitable"
|-
|-
| class || '''[[ContactInfo_Class|ContactInfo]]'''
| struct
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/ContactInfo_Class|ContactInfo]]'''
|-
|-
| enum || '''[[#LaunchReason-enum|LaunchReason]]''' { Unknown, StartAbility, Continuation, PrepareContinuation }
| enum class
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#LaunchReason-enum|LaunchReason]]''' { Unknown, StartAbility, Continuation, PrepareContinuation, Preload }
|}
|}


== Public Functions ==
== Public Functions ==


{| class="wikitable" style="width:100%"
{| class="wikitable"
|-
| virtual || '''[[#dtor.QOhosWantInfo|~QOhosWantInfo]]'''()
|-
|-
| virtual QtOhosExtras::QOhosWantInfo::LaunchReason || '''[[#launchReason|launchReason]]'''() const = 0
| virtual LaunchReason
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#launchReason|launchReason]]'''() const = 0
|-
|-
| virtual QSharedPointer<QtOhosExtras::QOhosWantInfo::ContactInfo> || '''[[#tryGetContactInfo|tryGetContactInfo]]'''() const = 0
| virtual QSharedPointer<ContactInfo>
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#tryGetContactInfo|tryGetContactInfo]]'''() const = 0
|-
|-
| virtual QSharedPointer<QList<QSharedPointer<ShareKit::QOhosSharedRecord>>> || '''[[#tryGetSharedRecordsFromShareKit|tryGetSharedRecordsFromShareKit]]'''() const = 0
| virtual QSharedPointer<QList<QSharedPointer<ShareKit::QOhosSharedRecord>>>
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#tryGetSharedRecordsFromShareKit|tryGetSharedRecordsFromShareKit]]'''() const = 0
|-
|-
| virtual QtOhosExtras::QOhosWant || '''[[#want|want]]'''() const = 0
| virtual QOhosWant
|}
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#want|want]]'''() const = 0
 
== Protected Functions ==
 
{| class="wikitable" style="width:100%"
|-
| || '''[[#QOhosWantInfo|QOhosWantInfo]]'''()
|}
|}


== Detailed Description ==
== Detailed Description ==


The QOhosWantInfo class is to represent Ohos want type.
== Member Type Documentation ==


== Member Type Documentation ==
=== <span id="LaunchReason-enum"></span>enum class QOhosWantInfo::LaunchReason ===


=== <span id="LaunchReason-enum"></span>enum QOhosWantInfo::LaunchReason ===
Enumerates the ability launch reasons. The value corresponds to launchParam.[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#launchReason|launchReason]] delivered by the platform and is obtained with [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#launchReason|QOhosWantInfo::launchReason]](). See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-app-ability-abilityconstant#launchreason AbilityConstant.LaunchReason].


{| class="wikitable"
{| class="wikitable"
! Constant !! Description
|-
|-
| Unknown || Launch reason is unknown.
! Constant
! Value
! Description
|-
|-
| StartAbility || Launched via a standard startAbility call.
| <code>QtOhosExtras::QOhosWantInfo::LaunchReason::Unknown</code>
| <code>0</code>
| Unknown reason.
|-
|-
| Continuation || Launched as part of an application continuation.
| <code>QtOhosExtras::QOhosWantInfo::LaunchReason::StartAbility</code>
| <code>1</code>
| The ability is started by calling [[Qt_for_HarmonyOS/qtohosextras_doc/QtOhosExtras_Namespace#startAbility|startAbility]].
|-
|-
| PrepareContinuation || Launched to prepare for a continuation.
| <code>QtOhosExtras::QOhosWantInfo::LaunchReason::Continuation</code>
| <code>2</code>
| The ability is started by means of cross-device migration.
|-
| <code>QtOhosExtras::QOhosWantInfo::LaunchReason::PrepareContinuation</code>
| <code>3</code>
| The ability is started in advance during cross-device migration.
|-
| <code>QtOhosExtras::QOhosWantInfo::LaunchReason::Preload</code>
| <code>4</code>
| The ability is started through preloading.
|}
|}
This enum was introduced or modified in Qt 5.12.12.


== Member Function Documentation ==
== Member Function Documentation ==


=== <span id="QOhosWantInfo"></span>[protected] QOhosWantInfo::QOhosWantInfo() ===
=== <span id="launchReason"></span><code>[pure virtual] </code>[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWantInfo_Class#LaunchReason-enum|LaunchReason]] QOhosWantInfo::launchReason() const ===


Default constructs an instance of QOhosWantInfo.
Returns the launch reason associated with this Want info. The value can be used to complete different operations, for example, during cross-device migration to distinguish the LaunchReason::PrepareContinuation and LaunchReason::Continuation steps.


=== <span id="dtor.QOhosWantInfo"></span>[virtual] QOhosWantInfo::~QOhosWantInfo() ===
<syntaxhighlight lang="cpp">


Destroys the instance of QOhosWantInfo. The destructor is virtual.
auto wantInfo = QtOhosExtras::QOhosAppContext::getAppLaunchWantInfo();
if (wantInfo->launchReason() == QtOhosExtras::QOhosWantInfo::LaunchReason::Continuation) {
    auto onContinueData = QtOhosExtras::tryGetOnContinueData(wantInfo->want());
    // restore the application state from onContinueData ...
}


=== <span id="launchReason"></span>[pure virtual] QtOhosExtras::QOhosWantInfo::LaunchReason QOhosWantInfo::launchReason() const ===
</syntaxhighlight>


Returns the launch reason for this Want.
'''See also '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosAbilityContext_Class#newWantInfoReceived|QOhosAbilityContext::newWantInfoReceived]]().


=== <span id="tryGetContactInfo"></span>[pure virtual] QSharedPointer<[[ContactInfo_Class|QtOhosExtras::QOhosWantInfo::ContactInfo]]> QOhosWantInfo::tryGetContactInfo() const ===
=== <span id="tryGetContactInfo"></span><code>[pure virtual] </code>[https://doc.qt.io/qt-5/qsharedpointer.html QSharedPointer]<[[Qt_for_HarmonyOS/qtohosextras_doc/ContactInfo_Class|ContactInfo]]> QOhosWantInfo::tryGetContactInfo() const ===


Tries to get contact information from the associated Want. Returns <code>nullptr</code> if no contact information is found. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section19799132782117 systemShare.getContactInfo].
Tries to get contact information from the associated Want. Returns <code>nullptr</code> if no contact information is found. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section19799132782117 systemShare.getContactInfo].


'''See also '''[[QOhosAbilityContext_Class#newWantInfoReceived|QOhosAbilityContext::newWantInfoReceived()]] and [[QOhosAppContext_Class#getAppLaunchWantInfo|QOhosAppContext::getAppLaunchWantInfo()]].
'''See also '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosAbilityContext_Class#newWantInfoReceived|QOhosAbilityContext::newWantInfoReceived]]() and [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosAppContext_Class#getAppLaunchWantInfo|QOhosAppContext::getAppLaunchWantInfo]]().


=== <span id="tryGetSharedRecordsFromShareKit"></span>[pure virtual] QSharedPointer<QList<QSharedPointer<[[QOhosSharedRecord_Class|ShareKit::QOhosSharedRecord]]>>> QOhosWantInfo::tryGetSharedRecordsFromShareKit() const ===
=== <span id="tryGetSharedRecordsFromShareKit"></span><code>[pure virtual] </code>[https://doc.qt.io/qt-5/qsharedpointer.html QSharedPointer]<[https://doc.qt.io/qt-5/qlist.html QList]<[https://doc.qt.io/qt-5/qsharedpointer.html QSharedPointer]<[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosSharedRecord_Class|ShareKit::QOhosSharedRecord]]>>> QOhosWantInfo::tryGetSharedRecordsFromShareKit() const ===


Tries to get shared records from associated want. Shared records are delivered on an application start or while the application is already running. Returns <code>nullptr</code> if no such data found. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section661613319216 systemShare.getSharedData].
Tries to get shared records from assosiated want. The shared data is expected to be stored in the want parameters. Shared records are delivered on an application start or while the application is already running. Returns <code>nullptr</code> if no such data found. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/share-system-share#section661613319216 systemShare.getSharedData].


'''See also '''[[QOhosAbilityContext_Class#newWantInfoReceived|QOhosAbilityContext::newWantInfoReceived()]] and [[QOhosAppContext_Class#getAppLaunchWantInfo|QOhosAppContext::getAppLaunchWantInfo()]].
'''See also '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosAbilityContext_Class#newWantInfoReceived|QOhosAbilityContext::newWantInfoReceived]]() and [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosAppContext_Class#getAppLaunchWantInfo|QOhosAppContext::getAppLaunchWantInfo]]().


=== <span id="want"></span>[pure virtual] QtOhosExtras::QOhosWant QOhosWantInfo::want() const ===
=== <span id="want"></span><code>[pure virtual] </code>[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWant_Class|QOhosWant]] QOhosWantInfo::want() const ===


Return associated with this instance [[QOhosWant_Class|QOhosWant]] object.
Return associated with this instance [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosWant_Class|QOhosWant]] object.


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

Latest revision as of 06:25, 17 September 2026

QOhosWantInfo Class

class QtOhosExtras::QOhosWantInfo

The QOhosWantInfo class is to represent Ohos want type. More...

Header: #include <QOhosWantInfo>
qmake: QT += ohosextras
Since: Qt 5.12.12

This class was introduced in Qt 5.12.12.

Public Types

struct ContactInfo
enum class LaunchReason { Unknown, StartAbility, Continuation, PrepareContinuation, Preload }

Public Functions

virtual LaunchReason launchReason() const = 0
virtual QSharedPointer<ContactInfo> tryGetContactInfo() const = 0
virtual QSharedPointer<QList<QSharedPointer<ShareKit::QOhosSharedRecord>>> tryGetSharedRecordsFromShareKit() const = 0
virtual QOhosWant want() const = 0

Detailed Description

Member Type Documentation

enum class QOhosWantInfo::LaunchReason

Enumerates the ability launch reasons. The value corresponds to launchParam.launchReason delivered by the platform and is obtained with QOhosWantInfo::launchReason(). See AbilityConstant.LaunchReason.

Constant Value Description
QtOhosExtras::QOhosWantInfo::LaunchReason::Unknown 0 Unknown reason.
QtOhosExtras::QOhosWantInfo::LaunchReason::StartAbility 1 The ability is started by calling startAbility.
QtOhosExtras::QOhosWantInfo::LaunchReason::Continuation 2 The ability is started by means of cross-device migration.
QtOhosExtras::QOhosWantInfo::LaunchReason::PrepareContinuation 3 The ability is started in advance during cross-device migration.
QtOhosExtras::QOhosWantInfo::LaunchReason::Preload 4 The ability is started through preloading.

This enum was introduced or modified in Qt 5.12.12.

Member Function Documentation

[pure virtual] LaunchReason QOhosWantInfo::launchReason() const

Returns the launch reason associated with this Want info. The value can be used to complete different operations, for example, during cross-device migration to distinguish the LaunchReason::PrepareContinuation and LaunchReason::Continuation steps.

 auto wantInfo = QtOhosExtras::QOhosAppContext::getAppLaunchWantInfo();
 if (wantInfo->launchReason() == QtOhosExtras::QOhosWantInfo::LaunchReason::Continuation) {
     auto onContinueData = QtOhosExtras::tryGetOnContinueData(wantInfo->want());
     // restore the application state from onContinueData ...
 }

See also QOhosAbilityContext::newWantInfoReceived().

[pure virtual] QSharedPointer<ContactInfo> QOhosWantInfo::tryGetContactInfo() const

Tries to get contact information from the associated Want. Returns nullptr if no contact information is found. See systemShare.getContactInfo.

See also QOhosAbilityContext::newWantInfoReceived() and QOhosAppContext::getAppLaunchWantInfo().

[pure virtual] QSharedPointer<QList<QSharedPointer<ShareKit::QOhosSharedRecord>>> QOhosWantInfo::tryGetSharedRecordsFromShareKit() const

Tries to get shared records from assosiated want. The shared data is expected to be stored in the want parameters. Shared records are delivered on an application start or while the application is already running. Returns nullptr if no such data found. See systemShare.getSharedData.

See also QOhosAbilityContext::newWantInfoReceived() and QOhosAppContext::getAppLaunchWantInfo().

[pure virtual] QOhosWant QOhosWantInfo::want() const

Return associated with this instance QOhosWant object.