MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rppqt/doxygen/from_signal.cpp:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 **/
12
13int main(int argc, char* argv[])
14{
15 QApplication app{argc, argv};
16
17 //! [from_signal]
18 QTextEdit* text_edit = new QTextEdit();
19 rppqt::source::from_signal(*text_edit, &QTextEdit::textChanged)
20 | rpp::ops::map([&](const auto&) {
21 return text_edit->toPlainText();
22 })
23 | rpp::ops::subscribe([](const QString& text) { std::cout << "text changed: " << text.toStdString() << std::endl; },
24 []() { std::cout << "text_edit destroyed!" << std::endl; });
25 text_edit->setText("123");
26 text_edit->setText("temp");
27 delete text_edit;
28 // Output:
29 // text changed: 123
30 // text changed: temp
31 // text_edit destroyed!
32 //! [from_signal]
33
34 return 0;
35}

Callers

nothing calls this directly

Calls 3

from_signalFunction · 0.85
mapFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected