QIfPendingReplyWatcher Class
The QIfPendingReplyWatcher provides signals for QIfPendingReply. More...
Header: | #include <QIfPendingReplyWatcher> |
qmake: | QT += interfaceframework |
Inherits: | QObject |
Properties
- resultAvailable : const bool
- success : const bool
- valid : const bool
- value : const QVariant
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 QIfPendingReplyWatcher holds all data of a QIfPendingReply and is implicitly shared between copies of the same QIfPendingReply instance. At the same time the watcher provides signals for when a result is ready or an error happened.
A QIfPendingReplyWatcher cannot be instantiated on its own. It is always created from a QIfPendingReply internally.
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 |
Notifier signal:
void | valueChanged(const QVariant &value) |
[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 |
Notifier signal:
void | valueChanged(const QVariant &value) |
[read-only]
valid : const bool
Holds whether the watcher 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 |
Notifier signal:
void | valueChanged(const QVariant &value) |
Member Function Documentation
[signal]
void QIfPendingReplyWatcher::replyFailed()
Emitted when the reply is marked as failed.
See also setFailed.
[signal]
void QIfPendingReplyWatcher::replySuccess()
Emitted when the reply is marked as successful.
See also setSuccess.
[invokable]
void QIfPendingReplyWatcher::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 QIfPendingReplyWatcher::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.
[invokable]
void QIfPendingReplyWatcher::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.
[signal]
void QIfPendingReplyWatcher::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.
© 2024 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.