QIfPendingReplyBase Class

The QIfPendingReplyBase is the base class for QIfPendingReply. More...

Header: #include <QIfPendingReplyBase>
qmake: QT += interfaceframework
Inherited By:

QIfPendingReply

Properties

  • value : const QVariant
  • watcher : QIfPendingReplyWatcher* 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
QIfPendingReplyWatcher *watcher() const

Detailed Description

QIfPendingReplyBase is the base class for QIfPendingReply 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 QIfPendingReply template class.

Property Documentation

[read-only] 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

[read-only] 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

[read-only] valid : const bool

Holds whether the QIfPendingReplyBase is valid

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

Access functions:

bool isValid() const

[read-only] value : const QVariant

Holds the current value of the QIfPendingReply

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

[read-only] watcher : QIfPendingReplyWatcher* const

Holds the watcher for the QIfPendingReply

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

Access functions:

QIfPendingReplyWatcher *watcher() const

Member Function Documentation

[invokable] void QIfPendingReplyBase::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.

[invokable] void QIfPendingReplyBase::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.

[invokable] void QIfPendingReplyBase::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.

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