QIviPendingReplyWatcher Class

The QIviPendingReplyWatcher provides signals for QIviPendingReply. More...

Header: #include <QIviPendingReplyWatcher>
qmake: QT += ivicore
Inherits: QObject

Properties

Public Functions

bool isResultAvailable() const
bool isSuccessful() const
bool isValid() const
void setFailed()
void setSuccess(const QVariant &value)
void then(const QJSValue &success, const QJSValue &failed = QJSValue())
QVariant value() const

Signals

void replyFailed()
void replySuccess()
void valueChanged(const QVariant &value)

Detailed Description

The QIviPendingReplyWatcher holds all data of a QIviPendingReply and is implicitly shared between copies of the same QIviPendingReply instance. At the same time the watcher provides signals for when a result is ready or an error happened.

A QIviPendingReplyWatcher cannot be instantiated on its own. It is always created from a QIviPendingReply internally.

Property Documentation

resultAvailable : const bool

Holds whether a result has been set

This property is true once a result has been set by using setSuccess() or setFailed().

Access functions:

bool isResultAvailable() const

Notifier signal:

void valueChanged(const QVariant &value)

success : const bool

Holds whether the reply succeeded

This property is true if the reply has a valid result set by calling setSuccess().

Access functions:

bool isSuccessful() const

Notifier signal:

void valueChanged(const QVariant &value)

valid : const bool

Holds whether the watcher is valid

A watcher can be invalid if a QIviPendingReplyBase is manually created not using the template class QIviPendingReply.

Access functions:

bool isValid() const

value : const QVariant

Holds the current value of the QIviPendingReply

If no result is available yet or the reply failed, a default constructed QVariant() is returned. Otherwise a QVariant holding the result is returned.

Access functions:

QVariant value() const

Notifier signal:

void valueChanged(const QVariant &value)

Member Function Documentation

[signal] void QIviPendingReplyWatcher::replyFailed()

Emitted when the reply is marked as failed.

See also setFailed.

[signal] void QIviPendingReplyWatcher::replySuccess()

Emitted when the reply is marked as successful.

See also setSuccess.

[signal] void QIviPendingReplyWatcher::valueChanged(const QVariant &value)

Emitted when the result for the reply is ready. This signal is called when the reply is successful as well as when it is failed. The value argument holds the result and is a default constructed QVariant in the failed case.

Note: Notifier signal for property resultAvailable. Notifier signal for property success. Notifier signal for property value.

See also setSuccess and setFailed.

void QIviPendingReplyWatcher::setFailed()

Marks the reply as failed.

Note: a result can only be set once and cannot be changed again later.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setSuccess.

void QIviPendingReplyWatcher::setSuccess(const QVariant &value)

Sets the result of the reply to value and marks the reply as succeeded.

The given value needs to be of the same type than the reply or convertible to that type.

Note: a result can only be set once and cannot be changed again later.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setFailed.

void QIviPendingReplyWatcher::then(const QJSValue &success, const QJSValue &failed = QJSValue())

Sets the JavaScript callbacks to be called once a result is delivered. If the reply succeeded the success callback is called, otherwise the failed callback.

The success callback can take the reply value as an argument.

The provided values need to be callable and constructed from a QJSEngine. Passing QJSValue objects created by C++ will result in an error.

Calling this function multiple times will override the existing callbacks.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

© 2020 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.