QDBusReply 类

template <typename T> class QDBusReply

QDBusReply 类将方法调用回复存储到远程对象。 更多...

头: #include <QDBusReply>
qmake: QT += dbus
Since: Qt 4.2

该类在 Qt 4.2 引入。

公共函数

QDBusReply (const QDBusError & error = QDBusError())
QDBusReply (const QDBusPendingReply<T> & reply )
QDBusReply (const QDBusPendingCall & pcall )
QDBusReply (const QDBusReply<T> & other )
QDBusReply (const QDBusMessage & reply )
QDBusReply<T> & operator= (const QDBusReply<T> & other )
QDBusReply<T> & operator= (const QDBusError & dbusError )
QDBusReply<T> & operator= (const QDBusPendingCall & pcall )
QDBusReply<T> & operator= (const QDBusMessage & reply )
const QDBusError & error () const
const QDBusError & error ()
bool isValid () const
QDBusReply::Type value () const
QDBusReply::Type operator QDBusReply::Type () const

详细描述

A QDBusReply object is a subset of the QDBusMessage object that represents a method call's reply. It contains only the first output argument or the error code and is used by QDBusInterface -derived classes to allow returning the error code as the function's return argument.

It can be used in the following manner:

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());
					

If the remote method call cannot fail, you can skip the error checking:

QString reply = interface->call("RemoteMethod");
					

However, if it does fail under those conditions, the value returned by QDBusReply<T>::value() is a default-constructed value. It may be indistinguishable from a valid return value.

QDBusReply objects are used for remote calls that have no output arguments or return values (i.e., they have a "void" return type). Use the isValid () function to test if the reply succeeded.

另请参阅 QDBusMessage and QDBusInterface .

成员函数文档编制

QDBusReply:: QDBusReply (const QDBusError & error = QDBusError())

Constructs an error reply from the D-Bus error code given by error .

QDBusReply:: QDBusReply (const QDBusPendingReply < T > & reply )

Constructs a QDBusReply object from the pending reply message, reply .

QDBusReply:: QDBusReply (const QDBusPendingCall & pcall )

Automatically construct a QDBusReply object from the asynchronous pending call pcall . If the call isn't finished yet, QDBusReply will call QDBusPendingCall::waitForFinished(), which is a blocking operation.

If the return types patch, QDBusReply will extract the first return argument from the reply.

QDBusReply:: QDBusReply (const QDBusReply < T > & other )

构造副本为 other .

该函数在 Qt 5.15 引入。

QDBusReply:: QDBusReply (const QDBusMessage & reply )

Automatically construct a QDBusReply object from the reply message reply , extracting the first return value from it if it is a success reply.

QDBusReply < T > &QDBusReply:: operator= (const QDBusReply < T > & other )

Makes this object be a copy of the object other .

QDBusReply < T > &QDBusReply:: operator= (const QDBusError & dbusError )

Sets this object to contain the error code given by dbusError . You can later access it with error ().

QDBusReply < T > &QDBusReply:: operator= (const QDBusPendingCall & pcall )

Makes this object contain the reply specified by the pending asynchronous call pcall . If the call is not finished yet, this function will call QDBusPendingCall::waitForFinished() to block until the reply arrives.

pcall finishes with an error message, this function will copy the error code and message into this object

pcall finished with a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it's not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

QDBusReply < T > &QDBusReply:: operator= (const QDBusMessage & reply )

Makes this object contain the reply message. If reply is an error message, this function will copy the error code and message into this object

reply is a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it's not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

const QDBusError &QDBusReply:: error () const

Returns the error code that was returned from the remote function call. If the remote call did not return an error (i.e., if it succeeded), then the QDBusError object that is returned will not be a valid error code ( QDBusError::isValid () will return false).

另请参阅 isValid ().

const QDBusError &QDBusReply:: error ()

这是重载函数。

bool QDBusReply:: isValid () const

返回 true if no error occurred; otherwise, returns false .

另请参阅 error ().

QDBusReply::Type QDBusReply:: value () const

Returns the remote function's calls return value. If the remote call returned with an error, the return value of this function is undefined and may be undistinguishable from a valid return value.

This function is not available if the remote call returns void .

QDBusReply::Type QDBusReply:: operator QDBusReply::Type () const

Returns the same as value ().

This function is not available if the remote call returns void .