Skip to content

Properties

Properties are values that can notify observers of changes. They can therefore be used as values in data bindings.

Unlike Qts Properties, KDBindings Properties don't require a Meta Object Compiler and are available in pure C++17. They can even be used outside of classes as free values.

Declaring Properties

Properties can be declared for most types by creating a KDBindings::Property<T> instance.

The property instance will then emit signals every time the properties value changes, the property is moved or destructed.

A minimal example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include <kdbindings/property.h>

using namespace KDBindings;

Property<std::string> myProperty;
myProperty.valueChanged().connect([](const std::string& value) {
  std::cout << value << std::endl;
});

myProperty = "Hello World!";
Expected output:
1
Hello World!

For more information and examples see the KDBindings::Property documentation.