ReactivePlusPlus
ReactiveX implementation for C++20
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>
auto rppqt::source::from_signal (const TObject &object, R(TSignalQObject::*signal)(Args...))
 Creates rpp::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>
auto rppqt::source::from_signal ( const TObject & object,
R(TSignalQObject::* signal )(Args...) )

Creates rpp::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)
| rpp::ops::map([&](const auto&) {
return text_edit->toPlainText();
})
| rpp::ops::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!
Examples
from_signal.cpp, and qt_readme.cpp.