QIviPendingReplyBase Class

The QIviPendingReplyBase is the base class for QIviPendingReply. More...

Header: #include <QIviPendingReplyBase>
qmake: QT += ivicore
Inherited By:

QIviPendingReply

Properties

  • value : const QVariant
  • watcher : QIviPendingReplyWatcher* const

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
QIviPendingReplyWatcher *watcher() const

Detailed Description

QIviPendingReplyBase is the base class for QIviPendingReply and provides QVariant based functions and properties for the usage from QML.

Usually you don't have to use this class, but instead always use the typesafe QIviPendingReply template class.

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

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

valid : const bool

Holds whether the QIviPendingReplyBase 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

watcher : QIviPendingReplyWatcher* const

Holds the watcher for the QIviPendingReply

Note: The QIviPendingReplyWatcher returned is owned by the QIviPendingReply and all its copies. If all copies of the QIviPendingReply get deleted its QIviPendingReplyWatcher gets deleted as well.

Access functions:

QIviPendingReplyWatcher *watcher() const

Member Function Documentation

void QIviPendingReplyBase::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 QIviPendingReplyBase::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 as the reply or be 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 QIviPendingReplyBase::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.