
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQDBusPendingReply class contains the reply to an asynchronous method callMore...
| Header: | #include <QDBusPendingReply> |
| Since: | Qt 4.5 |
| Inherits: | QDBusPendingCall |
| QDBusPendingReply() | |
| QDBusPendingReply(const QDBusPendingReply & other) | |
| QDBusPendingReply(const QDBusPendingCall & call) | |
| QDBusPendingReply(const QDBusMessage & message) | |
| QVariant | argumentAt(int index) const |
| Type | argumentAt() const |
| int | count() const |
| QDBusError | error() const |
| bool | isError() const |
| bool | isFinished() const |
| bool | isValid() const |
| QDBusMessage | reply() const |
| T1 | value() const |
| void | waitForFinished() |
| operator T1() const | |
| QDBusPendingReply & | operator=(const QDBusPendingReply & other) |
| QDBusPendingReply & | operator=(const QDBusPendingCall & call) |
| QDBusPendingReply & | operator=(const QDBusMessage & message) |
TheQDBusPendingReply class contains the reply to an asynchronous method call
TheQDBusPendingReply is a template class with up to 8 template parameters. Those parameters are the types that will be used to extract the contents of the reply's data.
This class is similar in functionality toQDBusReply, but with two important differences:
Where withQDBusReply you would write:
QDBusReply<QString> reply= interface->call("RemoteMethod");if (reply.isValid())// use the returned value useValue(reply.value());else// call failed. Show an error condition. showError(reply.error());
withQDBusPendingReply, the equivalent code (including the blocking wait for the reply) would be:
QDBusPendingReply<QString> reply= interface->asyncCall("RemoteMethod"); reply.waitForFinished();if (reply.isError())// call failed. Show an error condition. showError(reply.error());else// use the returned value useValue(reply.value());
For method calls that have more than one output argument, withQDBusReply, you would write:
QString reply= interface->call("RemoteMethod");
whereas withQDBusPendingReply, all of the output arguments should be template parameters:
QDBusPendingReply<bool,QString> reply= interface->asyncCall("RemoteMethod"); reply.waitForFinished();if (!reply.isError()) {if (reply.argumentAt<0>()) showSuccess(reply.argumentAt<1>());else showFailure(reply.argumentAt<1>()); }
QDBusPendingReply objects can be associated withQDBusPendingCallWatcher objects, which emit signals when the reply arrives.
See alsoQDBusPendingCallWatcher,QDBusReply, andQDBusAbstractInterface::asyncCall().
Creates an emptyQDBusPendingReply object. Without assigning aQDBusPendingCall object to this reply,QDBusPendingReply cannot do anything. All functions return their failure values.
Creates a copy of theotherQDBusPendingReply object. Just likeQDBusPendingCall andQDBusPendingCallWatcher, thisQDBusPendingReply object will share the same pending call reference. All copies share the same return values.
Creates aQDBusPendingReply object that will take its contents from thecall pending asynchronous call. ThisQDBusPendingReply object will share the same pending call reference ascall.
Creates aQDBusPendingReply object that will take its contents from the messagemessage. In this case, this object will be already in its finished state and the reply's contents will be accessible.
See alsoisFinished().
Returns the argument at positionindex in the reply's contents. If the reply doesn't have that many elements, this function's return value is undefined (will probably cause an assertion failure), so it is important to verify that the processing is finished and the reply is valid.
Returns the argument at positionIndex (which is a template parameter) cast to typeType. This function uses template code to determine the properType type, according to the type list used in the construction of this object.
Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed.
Return the number of arguments the reply is supposed to have. This number matches the number of non-void template parameters in this class.
If the reply arrives with a different number of arguments (or with different types), it will be transformed into an error reply indicating a bad signature.
Retrieves the error content of the reply message, if it has finished processing. If the reply message has not finished processing or if it contains a normal reply message (non-error), this function returns an invalidQDBusError.
Returns true if the reply contains an error message, false if it contains a normal method reply.
If the pending call has not finished processing, this function also returns true.
Returns true if the pending call has finished processing and the reply has been received. If this function returns true, theisError(),error() andreply() methods should return valid information.
Note that this function only changes state if you callwaitForFinished() or if an external D-Bus event happens, which in general only happens if you return to the event loop execution.
See alsoQDBusPendingCallWatcher::isFinished().
Returns true if the reply contains a normal reply message, false if it contains anything else.
If the pending call has not finished processing, this function return false.
Retrieves the reply message received for the asynchronous call that was sent, if it has finished processing. If the pending call is not finished, this function returns aQDBusMessage of typeQDBusMessage::InvalidMessage.
After it has finished processing, the message type will either be an error message or a normal method reply message.
Returns the first argument in this reply, cast to typeT1 (the first template parameter of this class). This is equivalent to callingargumentAt<0>().
This function is provided as a convenience, matching theQDBusReply::value() function.
Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed.
Suspends the execution of the calling thread until the reply is received and processed. After this function returns,isFinished() should return true, indicating the reply's contents are ready to be processed.
See alsoQDBusPendingCallWatcher::waitForFinished().
Returns the first argument in this reply, cast to typeT1 (the first template parameter of this class). This is equivalent to callingargumentAt<0>().
This function is provided as a convenience, matching theQDBusReply::value() function.
Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed.
Makes a copy ofother and drops the reference to the current pending call. If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
Makes this object take its contents from thecall pending call and drops the reference to the current pending call. If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
Makes this object take its contents from themessage message and drops the reference to the current pending call. If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
After this function is finished, theQDBusPendingReply object will be in its "finished" state and themessage contents will be accessible.
See alsoisFinished().
© 2016 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 theGNU 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.