using namespace rosetta;
struct Person {
[[ = doc{"the person's display name"} ]]
std::string name;
[[ = doc{"age in whole years"},
= range{0.0, 150.0},
= widget::slider ]]
int age = 0;
[[ = doc{"server-assigned identifier"},
= readonly{} ]]
std::string id;
[[ = rosetta::doc{"favourite colour"},
= rosetta::combobox{{"red", "green", "blue", "yellow"}} ]]
std::string color = "red";
Person() = default;
Person(std::string n, int a, std::string i): name(std::move(n)), age(a), id(std::move(i)) {}
[[ = doc{"Returns a greeting prefixed by the given salutation."} ]]
std::string greet(const std::string &salutation) const {
return salutation + ", " + name + "!";
}
void clear() {
name.clear();
age = 0;
}
};
Person person;
rosetta::ReflectedObject reflected;
rosetta::bind_qml<Person>(&reflected, person);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("inspector", &reflected);
