Jump to content

Qt for HarmonyOS/qtohosextras doc/QOhosStartRequest Class

From Qt Wiki
Revision as of 06:24, 17 September 2026 by Shawn Luo (talk | contribs) (Drop manual breadcrumb, MediaWiki renders it automatically (QTFOROH-2307))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

QOhosStartRequest Class

class QtOhosExtras::QOhosStartRequest

The QOhosStartRequest class emits signals for start ability. More...

Header: #include <QOhosStartRequest>
qmake: QT += ohosextras
Since: Qt 5.12.12
Inherits: QObject

This class was introduced in Qt 5.12.12.

Signals

void requestFailed(QOhosElementName elementName, QString message)
void requestSucceeded(QOhosElementName elementName, QString message)

Detailed Description

QOhosStartRequest adapts the StartOptions completionHandler into Qt signals. The requestSucceeded() and requestFailed() signals correspond to onRequestSuccess and onRequestFailure callbacks from the platform completion handler.

Create an instance using createStartRequest().

See Completion Handler.

 auto options = QtOhosExtras::createStartOptions();
 auto request = QtOhosExtras::createStartRequest(*options);

 QObject::connect(
     request.get(), &QtOhosExtras::QOhosStartRequest::requestSucceeded,
     [](const QtOhosExtras::QOhosElementName &elementName, const QString &message) {
         qDebug() << "started" << elementName.abilityName << message;
     });
 QObject::connect(
     request.get(), &QtOhosExtras::QOhosStartRequest::requestFailed,
     [](const QtOhosExtras::QOhosElementName &elementName, const QString &message) {
         qWarning() << "failed to start" << elementName.abilityName << message;
     });

 QtOhosExtras::QOhosWant want;
 want.bundleName = QStringLiteral("com.example.target");
 want.abilityName = QStringLiteral("EntryAbility");
 QtOhosExtras::startAbility(want, *request);

Member Function Documentation

[signal] void QOhosStartRequest::requestFailed(QOhosElementName elementName, QString message)

Signal emitted when the start request fails. It corresponds to the onRequestFailure callback of the platform completion handler. The elementName identifies the intended target ability; it may be left empty when the target cannot be resolved, for example when an implicit start fails. The message carries the failure information provided by the system as a JSON string. See onRequestFailure.

See also requestSucceeded().

[signal] void QOhosStartRequest::requestSucceeded(QOhosElementName elementName, QString message)

Signal emitted when the start request completes successfully. It corresponds to the onRequestSuccess callback of the platform completion handler. The elementName identifies the started ability and message carries additional information provided by the system. See onRequestSuccess.

See also requestFailed().