IntentClient QML Type

Singleton that provides functions to create Intent requests. More...

Import Statement: import QtApplicationManager 2.0

Properties

Methods

Detailed Description

This type can be used both in applications as well as within the System UI to create intent requests. This type is only the factory, returning instances of the type IntentRequest. See the IntentRequest documentation for details on how to actually handle these asynchronous calls.

Here is a fairly standard way to send an intent request and react on its result (or error message):

MouseArea {
    onClicked: {
        var request = IntentClient.sendIntentRequest("show-image", { url: "file://x.png" })
        request.onReplyReceived.connect(function() {
            if (request.succeeded)
                var result = request.result
            else
                console.log("Intent request failed: " + request.errorMessage)
        })
    }
}

Property Documentation

systemUiId : string

The hardcoded, special application id for targeting the System UI with an intent request.


Method Documentation

[since 6.5] bool broadcastIntentRequest(string intentId, var parameters)

Broadcasts an intent request with the given intentId to the system. The additional parameters are specific to the requested intentId, but the format is always the same: a standard JavaScript object, which can also be just empty if the requested intent doesn't require any parameters.

Broadcast requests do not generate replies. The return value is only ever false, if you call this function with invalid arguments.

This method was introduced in Qt 6.5.


IntentRequest sendIntentRequest(string intentId, var parameters)

Sends a request for an intent with the given intentId to the system. The additional parameters are specific to the requested intentId, but the format is always the same: a standard JavaScript object, which can also be just empty if the requested intent doesn't require any parameters.

Returns an IntentRequest object that can be used to track this asynchronous request.

Note: The returned object has JavaScript ownership, which means that you do not have to worry about freeing resources. Even just ignoring the return value is fine, if you are not interested in the result (or error condition) of your request.


IntentRequest sendIntentRequest(string intentId, string applicationId, var parameters)

This is an overloaded function.

Instead of letting the System UI (or the user) choose which application should handle your request, you can use this overload to hardcode the applicationId that is required to handle it. The request will fail, if this specified application doesn't exist or can't handle this specific request, even though other applications would be able to do it.

There is the special application id IntentClient.systemUiId which can be used to target the System UI.

See also sendIntentRequest.


© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.