Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDBusPendingCallWatcher Class

TheQDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous repliesMore...

Header:#include <QDBusPendingCallWatcher>
Since: Qt 4.5
Inherits:QObject andQDBusPendingCall

Public Functions

QDBusPendingCallWatcher(const QDBusPendingCall & call, QObject * parent = 0)
~QDBusPendingCallWatcher()
boolisFinished() const
voidwaitForFinished()

Signals

voidfinished(QDBusPendingCallWatcher * self)

Additional Inherited Members

Detailed Description

TheQDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous replies

TheQDBusPendingCallWatcher provides thefinished() signal that will be emitted when a reply arrives.

It is usually used like the following example:

QDBusPendingCall async= iface->asyncCall("RemoteMethod", value1, value2);QDBusPendingCallWatcher*watcher=newQDBusPendingCallWatcher(async,this);QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));

Note that it is not necessary to keep the originalQDBusPendingCall object around sinceQDBusPendingCallWatcher inherits from that class too.

The slot connected to by the above code could be something similar to the following:

void MyClass::callFinishedSlot(QDBusPendingCallWatcher*call){QDBusPendingReply<QString,QByteArray> reply=*call;if (reply.isError()) {        showError();    }else {QString text= reply.argumentAt<0>();QByteArray data= reply.argumentAt<1>();        showReply(text, data);    }    call->deleteLater();}

Note the use ofQDBusPendingReply to validate the argument types in the reply. If the reply did not contain exactly two arguments (one string and oneQByteArray),QDBusPendingReply::isError() will return true.

See alsoQDBusPendingReply andQDBusAbstractInterface::asyncCall().

Member Function Documentation

QDBusPendingCallWatcher::QDBusPendingCallWatcher(constQDBusPendingCall & call,QObject * parent = 0)

Creates aQDBusPendingCallWatcher object to watch for replies on the asynchronous pending callcall and sets this object's parent toparent.

QDBusPendingCallWatcher::~QDBusPendingCallWatcher()

Destroys this object. If thisQDBusPendingCallWatcher object was the last reference to the unfinished pending call, the call will be canceled.

[signal]void QDBusPendingCallWatcher::finished(QDBusPendingCallWatcher * self)

This signal is emitted when the pending call has finished and its reply is available. Theself parameter is a pointer to the object itself, passed for convenience so that the slot can access the properties and determine the contents of the reply.

bool QDBusPendingCallWatcher::isFinished() const

Returns true if the pending call has finished processing and the reply has been received.

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 alsoQDBusPendingReply::isFinished().

void QDBusPendingCallWatcher::waitForFinished()

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 alsoQDBusPendingReply::waitForFinished().

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


[8]ページ先頭

©2009-2025 Movatter.jp