![]() |
Home · All Classes · alphabetical Classes List · Modules · Functions · |
In many cases, writing code that assumes certain actions are synchronous is considerably simpler than breaking your function into multiple blocks and using signals and slots to connect them all. Using this class, QSignalWaiter::wait will block until a certain signal is emitted and then return. The return value is true if the signal was caught, or false if a user-specified timeout elapses before catching the signal.
void MyObject::myFunction() { QxtSignalWaiter waiter(myOtherObject, SIGNAL(longProcessFinished())); myOtherObject->longProcess(); if(waiter.wait(5000)) doSomething(myOtherObject->information()); else QMessageBox::information(0, "MyObject", "Timed out while waiting on longProcessFinished()", QMessageBox::Ok); }
default constructor Creates a QSignalWaiter and sets the default signal to sender::signal.
wait for signal Waits for the signal sender::signal to be emitted. If msec is not -1, wait() will return after msec milliseconds. If a signal is not specified, the default signal specified in the constructor is used instead. If no default signal was specified in the constructor, wait() will block until the timeout has elapsed. If no timeout was specified, wait() will return immediately.
Returns true if the signal was caught, false if it timed out.
This function is not reentrant.
(c) 2007A.Picciani and A.Higerd LGPL | libqxt 0.2 |