Reflection over class members?
-
So I suppose the short answer is "no".
What would it take to enable the Qt tools to generate information that would do real, first class reflection like one could do in C#? It seems like all the pieces are there - the moc tool would have to collect additional information and the QMetaObject would have to have some more code to let you get at the info.
Is this ridiculous of me to ask? If not, maybe I should make a feature request? I know that sometimes things that seem "easy" can in actuality be very complicated to do.
-
[quote author="medvedm" date="1325686847"]So I suppose the short answer is "no".
What would it take to enable the Qt tools to generate information that would do real, first class reflection like one could do in C#?[/quote]
Nothing. It would have to be added to the C++ core functionality.
-
[quote author="medvedm" date="1325686847"]So I suppose the short answer is "no".[/quote]
Yes.[quote author="medvedm" date="1325686847"]What would it take to enable the Qt tools to generate information that would do real, first class reflection like one could do in C#? It seems like all the pieces are there - the moc tool would have to collect additional information and the QMetaObject would have to have some more code to let you get at the info.[/quote]
Nothing (besides some minor modifications to <code>moc</code>). Yes.[quote author="medvedm" date="1325686847"]Is this ridiculous of me to ask? If not, maybe I should make a feature request? I know that sometimes things that seem "easy" can in actuality be very complicated to do.[/quote]
If there was such a feature request the quick answer would be: +1.
At least a single constructor should be included in the meta object, so that every QObject can be created at runtime. Not beeing able to do so as it is right now can be quite tedious.
In addition, I would prefer full reflection support in Qt over increased meta object size. Having a <code>--reflection</code> / <code>--no-reflection</code> configure switch could be used to enable and disable reflection.
-
Not sure why Volker dropped the smart-questions bomb. This doesn't seem like an unreasonable question to me. RTTI doesn't do what I am asking for, and I don't think it would have to be added in base C++.
Qt is already pulling information out about classes I write via moc, so I suppose that is why I'm asking if it is difficult to pull out some more information and make it available to users.
-
[quote author="medvedm" date="1325690312"]
Not sure why Volker dropped the smart-questions bomb. This doesn't seem like an unreasonable question to me. RTTI doesn't do what I am asking for, and I don't think it would have to be added in base C++.
[/quote]The bomb is in the signature, everyone gets it and once I purge it, it's out of every reply :-) you can have your own signature, it's in the "edito profile"/member/profile link.
[quote author="medvedm" date="1325690312"]
Qt is already pulling information out about classes I write via moc, so I suppose that is why I'm asking if it is difficult to pull out some more information and make it available to users.[/quote]
It would work only with QObject based classes, not for plain old classes - and for that be restricted anyways. For accessing members (you mean member methods or member attributes here?) you have the slots (for methods) and the properties (for attributes). Nothing prevents you from declaring every method as a slot, and providing a property for every attribute. I agree that the latter is cumbersome and adds some boilerplate.