Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: list of dynamic properties set on a given QObject?

Using QMetaObject I am able to browse all properties defined at compile-time using Q_PROPERTY macro...

Now I would be able to browse all dynamic properties added at run-time using setProperty()...

Is it possible?

like image 361
Morix Dev Avatar asked Jan 22 '26 23:01

Morix Dev


1 Answers

You can get the list of all dynamic properties using QObject::dynamicPropertyNames(). For example:

QList<QByteArray> dynamicProperties = object->dynamicPropertyNames();

To get the property value use the same QObject::property(const char * name ) function:

QVariant val = object->property(name );
like image 53
vahancho Avatar answered Jan 24 '26 14:01

vahancho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!