Am 16.12.2023 um 09:21 schrieb apoenitz:
I haven't tried yet, but I have the gut feeling that one should be able
to get away with
Seems your gut feeling is right. Did a little experiment[1], and ended
up with this:
class MyObject :public Object<MyObject, QObject>
{
M_OBJECT
public:
using Object::Object;
void modifyNotifying()
{
notifying =u"I have been changed per method"_s;
}
Property<n(), QString> constant =u"I am constant"_s;
Property<n(), QString, Notify> notifying =u"I am observing"_s;
Property<n(), QString, Write> writable =u"I am modifiable"_s;
Setter<QString> setWritable = &writable;
static constexpr Signal<&MObject::notifying> notifyingChanged = {};
static constexpr Signal<&MObject::writable> writableChanged = {};
};
Plus this tiny bit of boilerplate:
template<>
std::vector<MyObject::MetaProperty> MyObject::MetaObject::makeProperties()
{
return {
{"constant", &null()->constant}, // FIXME: with some
additional effort
{"notifying", &null()->notifying}, // &MObject::constant
should be possible
{"writable", &null()->writable},
};
}
M_OBJECT_IMPLEMENTATION(MObject, constant, notifying, writable)
Grab it from: https://github.com/hasselmm/PropertyExperiment
Warning: There will be dragons! It's just a proof of concept with
terrible shortcuts,
not even remotely production quality.
Ciao
Mathias
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development