An example of how to create a KDBindings::Property and use its valueChanged() KDBindings::Signal to receive notifications whenever the value of the KDBindigns::Property changes.
The output of this example is:
The new value is 42
The new value is 69
Property value is 69
#include <iostream>
#include <string>
class Widget
{
public:
Widget(std::string const &name)
: value(0)
, m_name(name)
{
}
Property<int> value;
private:
std::string m_name;
};
int main()
{
Widget w("A cool widget");
(void)w.value.valueChanged().connect([](int newValue) {
std::cout << "The new value is " << newValue << std::endl;
});
w.value = 42;
w.value = 69;
std::cout << "Property value is " << w.value << std::endl;
return 0;
}
The main namespace of the KDBindings library.