ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
QT Creational Operators

QT creational operators are operators that create new observable from QObjects. More...

Functions

template<std::derived_from< QObject > TSignalQObject, std::derived_from< TSignalQObject > TObject, typename R , typename ... Args>
requires rpp::details::is_header_included<rpp::details::from_signal_qt_tag, TObject, R, Args...>
auto rppqt::observable::from_signal (const TObject &object, R(TSignalQObject::*signal)(Args...))
 Creates rpp::specific_observable that emits a items from provided QT signal.
 

Detailed Description

QT creational operators are operators that create new observable from QObjects.

Function Documentation

◆ from_signal()

template<std::derived_from< QObject > TSignalQObject, std::derived_from< TSignalQObject > TObject, typename R , typename ... Args>
requires rpp::details::is_header_included<rpp::details::from_signal_qt_tag, TObject, R, Args...>
auto rppqt::observable::from_signal ( const TObject &  object,
R(TSignalQObject::*)(Args...)  signal 
)

Creates rpp::specific_observable that emits a items from provided QT signal.

Parameters
objectis QObject which would emit signals
signalis interested signal which would generate emissions for observable. Expected to obtain pointer to member function representing signal
Examples:
QTextEdit* text_edit = new QTextEdit();
rppqt::source::from_signal(*text_edit, &QTextEdit::textChanged).map([&](const auto&)
{
return text_edit->toPlainText();
}).subscribe([](const QString& text) { std::cout << "text changed: " << text.toStdString() << std::endl;},
[](){ std::cout << "text_edit destroyed!" << std::endl; });
text_edit->setText("123");
text_edit->setText("temp");
delete text_edit;
// Output:
// text changed: 123
// text changed: temp
// text_edit destroyed!