Qt 的活性扩展 .
The Reactive Extensions for Qt.
…observable rxqt::from_signal(const QObject* sender, PointerToMemberFunction signal);Convert Qt signal to an observable. T is decided as following.
| Signal parameter type(s) | T | Note |
|---|---|---|
void |
long |
Count of signal emission |
A0 |
A0 |
|
A0, A1, ..., An (n > 1) |
tuple |
template
observable rxqt::from_signal(const QObject* sender, PointerToMemberFunction signal);Convert Qt signal, as N-ary function, to an observable. This can be used to convert private signals.
auto o = from_signal(q, &QFileSystemWatcher::fileChanged); // ERROR. o is observable> where last type is private member.
auto o = from_signal(q, &QFileSystemWatcher::fileChanged); // OK. o is observableobservable rxqt::from_event(QObject* object, QEvent::Type type);Convert Qt event to an observable.
Provide an interface between the Qt event loop and RxCpp's run loop scheduler. This enables use of timed RxCpp operators (such as delay and debounce) with RxQt.
Using run_loop requires an object of type run_loop to be live while the Qt event loop is active. This can be achieved most simply through use of a local variable defined after the Qt application object has been instantiated in main, or wherever the applicaiton object is instantiated. The example below gives an example of appropriate instantiation of the run_loop, together with a main window class of MainWindow:
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
rxqt::run_loop rxqt_run_loop;
w.show();
return a.exec();
}Issues or Pull Requests are welcomed :)
rxqt::run_loop)暂无开放 Issues,或尚未同步最近议题。