KDBindings API Documentation  1.0.95
02-signal-member/main.cpp

An example of how to connect a member function to a KDBindings::Signal.

The output of this example is:

Hello World!
/*
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;
class Button
{
public:
Signal<> clicked;
};
class Message
{
public:
void display() const
{
std::cout << "Hello World!" << std::endl;
}
};
int main()
{
Button button;
Message message;
auto connection = button.clicked.connect(&Message::display, &message);
button.clicked.emit();
connection.disconnect();
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