KDBindings API Documentation  1.0.95
01-simple-connection/main.cpp

A simple example of how to create a KDBindings::Signal and connect a lambda to it.

The output of this example is:

The answer: 42
/*
This file is part of KDBindings.
SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sean Harmer <sean.harmer@kdab.com>
SPDX-License-Identifier: MIT
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <iostream>
#include <string>
using namespace KDBindings;
int main()
{
// Create new signal
Signal<std::string, int> signal;
// Connect a lambda
(void)signal.connect([](std::string arg1, int arg2) {
std::cout << arg1 << " " << arg2 << std::endl;
});
// Emit the signal and the lambda is called
signal.emit("The answer:", 42);
return 0;
}
The main namespace of the KDBindings library.
Definition: binding.h:21

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDBindings
Reactive programming & data binding in C++
https://github.com/KDAB/KDBindings/
Generated by doxygen 1.9.1