1

I have this property:

Q_PROPERTY(int _a READ a WRITE setA NOTIFY aChanged)

I know only the property's name _a. I would like get the index of the method setA.

artoon
  • 729
  • 2
  • 14
  • 41

1 Answers1

1

Check out QMetaObject::indexOfProperty(const char * name) and QMetaProperty QMetaObject::property(int index). They will allow you to access the property by name.

AFAIK there is now way to access a setter method via the corresponding property.

Silicomancer
  • 8,604
  • 10
  • 63
  • 130
  • Yes but, when you have the QProperty how get the index of the write method? – artoon Aug 29 '14 at 14:53
  • There is a write() method in QProperty, isn't this enough? I don't know a way how to actually get the function itself. – Silicomancer Aug 29 '14 at 15:34
  • No, it isn't enough. There is QMetaMethod QMetaProperty::notifySignal(). I would like QMetaMethod QMetaProperty::writeMethod(). – artoon Sep 01 '14 at 06:26
  • AFAIK there is no way to access the setter this way. I updated my answer so you can accept it if no actual solution arises. Maybe you should add a suggestion to the Qt bug-tracker (however I have the impression that most suggestions and even many bug reports are ignored since Digia is responsible for Qt). – Silicomancer Sep 01 '14 at 07:19